-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Hi Team,
I have developed a custom .NET Core profiler using Visual Studio 2019. To load the profiler, I’ve configured the environment variables in the web.config file as follows:
<environmentVariable name="CORECLR_ENABLE_PROFILING" value="1" />
<environmentVariable name="CORECLR_PROFILER" value="{cf0d821e-299b-5307-a3d8-b283c03916dd}" />
<environmentVariable name="CORECLR_PROFILER_PATH_64" value="C:\apps\Publish_3.0\Publish_3.0\ClrProfiler.dll" />
<environmentVariable name="CORECLR_PROFILER_PATH_32" value="C:\apps\Publish_3.0\Publish_3.0\ClrProfiler32.dll" />
With this setup, I'm able to successfully profile a 64-bit .NET Core application hosted in IIS.
However, when attempting to profile a 32-bit .NET Core application, I encounter the following error:
[aspnetcorev2_inprocess.dll] Event Log:
'Application '/LM/W3SVC/5/ROOT' with physical root 'E:\netcoreapp\bin\Release\netcoreapp3.1\publish' hit unexpected managed exception, exception code = '0xe0434352'.
First 30KB characters of captured stdout and stderr logs:
Unhandled exception. System.BadImageFormatException: Bad binary signature. (0x80131192)
at net_core_azure.Program.Main(String[] args)
End Event Log Message.
To troubleshoot, I enabled debug logs in the profiler. The issue appears to originate from the following block of code in
il_writer.cpp, at line 636:
HRESULT ILRewriter::SetILFunctionBody(unsigned size, LPBYTE pBody)
{
if (m_pICorProfilerFunctionControl != nullptr)
{
// We're supplying IL for a ReJIT scenario
IfFailRet(m_pICorProfilerFunctionControl->SetILFunctionBody(size, pBody));
}
else
{
// Classic instrumentation during the first JIT compilation
// Issue appears to be with the following line (line 636)
IfFailRet(m_pICorProfilerInfo->SetILFunctionBody(m_moduleId, m_tkMethod, pBody));
}
}
Additional Information:
The helper assembly is built with .NET Standard 2.0.
Both 32-bit and 64-bit VC++ Redistributables are installed on the machine.
Followed this URL to develop my custom profiler,
https://github.com/microsoftarchive/clrprofiler/blob/master/ILRewrite/ILRewriteProfiler/ilrewriter.cpp
Already raised questions in the following URL,
https://learn.microsoft.com/en-us/answers/questions/785908/net-core-profiler-crashing-on-32-bit-application-e
Request:
Could you please help identify why the 32-bit application fails when using the profiler, particularly at SetILFunctionBody()? Are there known issues or how to fix this issue ?
Thank you,
Expected Behavior
Our expectation is that the profiler should support both 32-bit and 64-bit applications.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
Helperassembly file builds with .NET standard 2.0
Anything else?
No response