DataDog/dd-trace-dotnet

Profiler uses environment variables instead of current module for pinvoke generation

wiktork opened this issue · 1 comments

When emitting pinvokes, GetCLRProfilerPath uses CORECLR_PROFILER_PATH to figure out the location of the native profiler module. While this works in most cases, it can cause issues in some scenarios:

  • Raw Profiler Hook scenarios will not work, since the environment variable is set to the CLR Instrumentation Engine.
  • It's possible for the process to change its environment variables, changing the behavior of GetCLRProfilerPath.

On Windows this could be done using GetModuleHandleEx/GetModuleFileName.
On Linux this could be done using dladdr.

PR with the fix has been merged and it's expected to be out as part of the 2.0 release.
Closing this issue.