Uh oh!
There was an error while loading. Please reload this page.
Preserve last error for patchpoint helpers - #75922
Conversation
In stress modes (and eventually perhaps in normal uses) the jit may insert patchpoint helper calls in regions where last error is live. So the helpers need to preserve last error. Because some invocations of the helpers may transition to OSR methods instead of returning, we can't use the normal macros for this. Fixesdotnet#75828.
ghost
commented
Sep 20, 2022
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsIn stress modes (and eventually perhaps in normal uses) the jit may insert patchpoint helper calls in regions where last error is live. So the helpers need to preserve last error. Because some invocations of the helpers may transition to OSR methods instead of returning, we can't use the normal macros for this. Fixes #75828.
|
AndyAyersMS
commented
Sep 20, 2022
@jakobbotsch PTAL Seems like EnC could hit this issue too? |
| void JIT_Patchpoint(int* counter, int ilOffset) | ||
| { | ||
| // BEGIN_PRESERVE_LAST_ERROR; | ||
| DWORD __dwLastError = ::GetLastError(); |
There was a problem hiding this comment.
| DWORD__dwLastError = ::GetLastError(); | |
| DWORDdwLastError = ::GetLastError(); |
| void JIT_PartialCompilationPatchpoint(int ilOffset) | ||
| { | ||
| // BEGIN_PRESERVE_LAST_ERROR; | ||
| DWORD __dwLastError = ::GetLastError(); |
There was a problem hiding this comment.
| DWORD__dwLastError = ::GetLastError(); | |
| DWORDdwLastError = ::GetLastError(); |
jkotas
commented
Sep 20, 2022
I do not see any obvious problem. EnC patch runs inside debugger step handler that is preserving last error: runtime/src/coreclr/vm/exceptionhandling.cpp Line 857 in 5384105 |
AndyAyersMS
commented
Sep 20, 2022
OSX seems to have some networking issues: |
stephentoub
commented
Sep 20, 2022
Yeah, almost every PR today has failed most mac legs because of that. @MattGal is investigating. |
MattGal
commented
Sep 20, 2022
The "normal" channels are being a bit slow but I have confirmed they're aware of the throttling problem and are trying to identify the cause presently. |
jkotas
commented
Sep 21, 2022
Is this .NET 7 backport candidate? (Intermittent data corruption caused by OSR.) |
AndyAyersMS
commented
Sep 21, 2022
I don't know if we can hit this with normal OSR. The failure above is from a stress mode that places patchpoints in randomly selected blocks where the stack is empty, whereas OSR normally will only place patchpoints at blocks that are the start or end of a loop. I'll spend some time today trying to work up a case; seems like the "end of loop" patchpoint (which is the default placement) might be a place we could hit this normally. |
jkotas
commented
Sep 21, 2022
I would expect that something like this can hit this reliably: |
AndyAyersMS
commented
Sep 21, 2022
Yes, thanks. Repro is simple and deterministic; the failure happens in Tier0 code once it has invoked the patchpoint helper. Will add a test case. |
For Linxu arm64 NAOT: msbuild crashed during restore: Similar perhaps to #43826 but that issue is quite old. |
AndyAyersMS
commented
Sep 22, 2022
@jeffschwMSFT@JulieLeeMSFT we should consider porting this to 7.0. |
jeffschwMSFT
commented
Sep 22, 2022
@AndyAyersMS in what cases (beyond stress modes) do we anticipate that this may occur? |
AndyAyersMS
commented
Sep 22, 2022
This PR has a simple test case that fails without stress -- the value of last error will not be preserved across loops. |
In a more real-world situation, the long-running for-loop in the test can be some kind of interop marshalling code. |
AndyAyersMS
commented
Sep 26, 2022
/backport to release/7.0 |
Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/3130148038 |
In stress modes (and eventually perhaps in normal uses) the jit may insert patchpoint helper calls in regions where last error is live. So the helpers need to preserve last error.
Because some invocations of the helpers may transition to OSR methods instead of returning, we can't use the normal macros for this.
Fixes#75828.