License Type | SaaS | On-Premise |
Agent Mode | Assess | Protect |
Main Product Category | .NET Core Agent |
Sub Category | Configuration |
Issue
When running a .NET 6 application with a debugger attached (for example within Visual Studio) after installation and configuration of the .NET Core agent, the sensor fails to initialize and the following errors are found in the agent logs:
In the Profiler log:
ERROR ReJitProvider::InvokeReJIT failed RequestReJIT [0x80131383]
In the Sensor log:
ERROR SensorsInitializer Error during sensors initialization. Exception: Contrast.Sensors.Instrumentation.Profiler.ReJitInitializationException: Calling 'CoreClrInitializeRejitProfiler' for ReJIT failed. Check profiler logs for errors.\r\n at Contrast.Sensors.Instrumentation.Profiler.PolicyExporter.ExportPolicyToProfiler(AgentPolicy policy)\r\n at Contrast.Sensors.Instrumentation.DiagnosticTimings.WrappedPolicyExporter.ExportPolicyToProfiler(AgentPolicy policy)\r\n at Contrast.Sensors.Startup.SensorsInitializer.InitializeSensors()\r\n at Contrast.Sensors.Startup.SensorsInitializer.Initialize()
Cause
Due to these changes in .NET 6 - calling RequestReJITWithInliners
with a debugger attached will fail with the HRESULT
of 0x80131383 CORPROF_E_REJIT_INLINING_DISABLED
This occurs due to DisableDefaultCodeVersioning
in [release/6.0] Deadlock mitigation for debugging by davmason · Pull Request #69121 · dotnet/runtime causing ReJitManager::IsReJITInlineTrackingEnabled
to return false.
Note: This only occurs if the debugger is attached at startup, and is not present in .NET 5 or .NET 7
Resolution
Contrast is working on a change to the agent to work around this issue however at the present time users can avoid this error by either:
- Running without the debugger attached
- Use .NET 7
- Set the environment variable
DOTNET_EXTERNAL_DebuggerLaunchDisablesCodeVersioning=0