-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix invalid IL in profiler stub helper #45453
Conversation
Tagging subscribers to this area: @tommcdon Issue DetailsFixes #45411 Profilers can set COR_PRF_MONITOR_CODE_TRANSITIONS to be notified when a PInvoke, COM call, etc causes execution to leave or enter the runtime. It works by injecting some additional IL in the transition stubs. The injected IL was loading integer constants of 0 for the pThis argument of StubHelpers.ProfilerBeginTransitionCallback(IntPtr pSecretParam, IntPtr pThread, object pThis). This worked fine but was technically illegal according to the spec. The first two arguments do want an integer constant for the IntPtr, but the third is a reference and needs to be a reference type. #44506 added checks that would cause the JIT to throw an InvalidProgramException if illegal implicit casts were detected, causing some profiler tests to fail.
|
@sandreenko while investigating and testing this I found out that the checks you added in #43386 are ignored if the call ends up being inlined. That seems counter intuitive to me, I am not sure if you know about that already so I thought I would point it out. |
I am not sure what you mean, do we try to inline a method that does not pass impCheckImplicitArgumentCoercion` checks? Could you give me an example? I can imagine a situation where we have 3 calls: runtime/src/coreclr/src/jit/importer.cpp Line 19537 in cd5619b
|
@sandreenko nevermind, I reran my tests and I see them failing even with inlined methods. Last night when I was testing I must have been changing multiple things at once, |
1d5b0ab
to
a4a5f5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I don't know this code area well.
Fixes #45411
Profilers can set COR_PRF_MONITOR_CODE_TRANSITIONS to be notified when a PInvoke, COM call, etc causes execution to leave or enter the runtime. It works by injecting some additional IL in the transition stubs. The injected IL was loading integer constants of 0 for the pThis argument of StubHelpers.ProfilerBeginTransitionCallback(IntPtr pSecretParam, IntPtr pThread, object pThis). This worked fine but was technically illegal according to the spec. The first two arguments do want an integer constant for the IntPtr, but the third is a reference and needs to be a reference type.
#43386 added checks that would cause the JIT to throw an InvalidProgramException if illegal implicit casts were detected, causing some profiler tests to fail.