Repository navigation
Conversation
The interface dispatch slow path cannot unwind into funclets on x86 since it does not know the size of the callee-popped arguments. Fixes dotnet#138481
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
|
I do not think this is a complete fix. The same problem exists outside funclets as well. This is Copilot generated repro that is still crashing with the fix in the PR: |
|
We may want to switch NAOT x86 to the ldftn plan unconditionally. It may be a bit slower, but I do not think we care. |
Co-authored-by: Cursor <cursoragent@cursor.com>
The interface dispatch slow path does not know the size of the callee-popped arguments, so it cannot unwind to the caller correctly outside funclets either: pending pushed GC refs of an outer call in partially interruptible code were misreported. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Let's wait for #137436 to be merged first. We should be able to delete a bit of x86 asm code for the non-ldftn resolution helper. |
There was a problem hiding this comment.
🟡 Changes recommended
Standalone interface ldvirtftn on NativeAOT x86 still supplies a thunk where the importer expects a dispatch cell, risking a crash when the function pointer is invoked via calli.
1 open issue
What changed in this PR
This PR addresses NativeAOT x86 stack-unwinding corruption reported in #138481 by resolving interface calls through a helper before invoking the target.
Changes:
- Enables helper-based interface resolution for NativeAOT x86 in the compiler and JIT importer.
- Maps fast interface resolution to
RhpDispatchResolve. - Adds regression tests for interface calls inside catch handlers and calls with pending GC-reference arguments.
| File | Description |
|---|---|
src/tests/Regressions/coreclr/GitHub_138481/test138481.csproj |
Registers the regression test source and test-library reference. |
src/tests/Regressions/coreclr/GitHub_138481/test138481.cs |
Exercises interface resolution during GC in both affected scenarios. |
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs |
Selects helper-based interface dispatch on x86. |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/KnownExternFunctions.cs |
Supplies the resolver mapping and helper signature. |
src/coreclr/jit/importer.cpp |
Extends NativeAOT interface lookup handling to x86. |
Review effort: Balanced
| @@ -1612,8 +1612,10 @@ private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESO | |||
| && ((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_LDFTN) == 0 | |||
| || _compilation.TypeSystemContext.Target.Architecture == TargetArchitecture.Wasm32)) | |||

The interface dispatch slow path cannot unwind into funclets on x86
since it does not know the size of the callee-popped arguments.
Fixes #138481