Skip to content

Commit 5c087d9

Browse files
Fix github60486 AOT caller identity and frame enumeration (#133775)
## Summary This fixes #133798 Fix the two AOT failures exposed by the expanded `github60486` regression in #133707 and observed in CI for #133774. - Preserve callers of the stack-walk implementation of `MethodBase.GetCurrentMethod` during Mono LLVM inlining. The LLVM-only intrinsic already prevents inlining; the stack-walk path needs the same protection. The test's inlineable helper remains unannotated. - Allow unrelated NativeAOT stack frames to lack reflection metadata. A local diagnostic run identified `TestEntryPoint` as the frame returning null from `GetMethod`; all four recursive frames returned valid method metadata. Keep the exact four-frame assertion and all existing DIM, exception-stack, caller-identity, and GC-root checks. Related caller-inlining report: #60334. Its iOS configuration was not tested here. ## Validation Built Checked CoreCLR/NativeAOT and Release Mono with LLVM from a clean baseline in the same worktree. | Windows x64 configuration | Before | After | |---|---|---| | NativeAOT Checked | Reported null-reference failure | Pass | | Mono LLVM AOT Release | Expected `GetCurrentMethodInlineable`, actual `ValidateCurrentMethod` | Pass | | CoreCLR Checked | Pass | Pass | | Mono MiniJIT Release | Pass | Pass | Each run executes the full standalone `github60486` regression. Mono LLVM AOT comparisons use identical test IL, and runtime logging confirms the fixed AOT image is loaded. LLVM IR adds `noinline` to the inlineable and generic wrappers; the optimized caller retains the helper call instead of inlining it. No performance claim is made. The Windows Mono LLVM AOT reproduction matches the Linux CI failure signature. Linux and browser Wasm were not run locally. The Windows x64 JIT formatting check completed successfully. > [!NOTE] > This change and pull request description were developed with GitHub Copilot assistance. Co-authored-by: Copilot App <[email protected]>
1 parent 3c245fd commit 5c087d9

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/mono/mono/mini/intrinsics.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,6 +2078,9 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
20782078
mini_set_inline_failure (cfg, "MethodBase:GetCurrentMethod ()");
20792079
return ins;
20802080
}
2081+
2082+
/* The stack-walk implementation also needs its caller to survive LLVM inlining. */
2083+
cfg->no_inline |= COMPILE_LLVM (cfg) && !strcmp (cmethod->name, "GetCurrentMethod");
20812084
} else if (cmethod->klass == mono_class_try_get_math_class ()) {
20822085
/*
20832086
* There is general branchless code for Min/Max, but it does not work for

‎src/tests/Loader/classloader/DefaultInterfaceMethods/regressions/github60486.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ private static void ValidateRecursiveCurrentMethod(int depth)
168168
int frameCount = 0;
169169
foreach (System.Diagnostics.StackFrame frame in new System.Diagnostics.StackTrace().GetFrames())
170170
{
171-
if (frame.GetMethod().Name == nameof(ValidateRecursiveCurrentMethod))
171+
// NativeAOT can omit reflection metadata for unrelated callers.
172+
if (frame.GetMethod()?.Name == nameof(ValidateRecursiveCurrentMethod))
172173
{
173174
frameCount++;
174175
}

0 commit comments

Comments
 (0)