Repository navigation
Commit a7fda7e
[wasm] Fix caller identification across R2R prestub transitions (dotnet#133707)
Fixes dotnet#133617.
## Problem
The Wasm portable-entrypoint slow path retains a `PrestubMethodFrame`
while invoking a resolved R2R body. Function-only stack walks can report
both the real managed activation and that transition frame.
`MethodBase.GetCurrentMethod` can therefore accept its own prestub frame
as the caller.
A Checked-runtime capture confirmed this: the stack marker was
`0x4fe71c`; the real `GetCurrentMethod` body at SP `0x4fe710` did not
pass the caller-marker comparison, but its explicit `PrestubMethodFrame`
at SP `0x4fe720` did. The result was `GetCurrentMethod` instead of the
calling method. This also reproduces without trimming.
dotnet#133610 addressed the duplicate in `GetStackFramesCallback`, but
caller-sensitive reflection uses a different callback and did not
benefit from that filter.
## Change
- Mark completed non-FCall Wasm prestub transitions as not representing
an additional managed activation.
- Filter those frames centrally for `FUNCTIONSONLY` walks, covering both
ordinary and skipped explicit frames.
- Retain the frame, MethodDesc, argument-root reporting, and physical
unwind/exception lifetime. Popping early or clearing the MethodDesc
would lose GC protection and the unwind bridge across interpreter-to-R2R
transitions.
- Replace dotnet#133610's StackTrace-specific adjacency filter. Filtering by
lifecycle rather than matching method identities preserves genuine
recursion.
- Extend the existing `github60486` regression with
direct/inlineable/generic caller identity, assembly lookup, recursive
frame counts, and compacting-GC object/byref/struct argument coverage.
Its original DIM frame-sequence and exception-stack checks remain
intact.
Native FCalls retain their existing representation. Non-Wasm filtering
behavior is unchanged.
## Validation
### CoreCLR runtime regression
Built browser-Wasm and macOS arm64 Checked runtimes with Release
libraries. The expanded
`Loader/classloader/DefaultInterfaceMethods/regressions/github60486`
passes with fixed Wasm R2R, the interpreter, and native arm64. The
identical final regression assembly fails against the saved original
Wasm runtime: expected `ValidateCurrentMethod`, actual
`GetCurrentMethod`.
These fixed runs include the original regression checks from dotnet#133610,
with its `debugdebugger.cpp` filter removed.
### Original browser library lane
Validated the exact patch in an isolated checkout of dotnet#133656 at
`282d12dfe220a1f34d0bb81a85239cab60c779ce`, which supplies the browser
R2R publishing/test prerequisites. Built matched original/fixed CoreCLR
Release products locally and ran Chromium 153. Temporarily enabled only
the nine dotnet#133617-quarantined methods, preserving every original
assertion and unrelated exclusion; all annotations were restored
afterward. This PR contains no library-test quarantine changes.
| Coverage | Original | Fixed |
|---|---:|---:|
| Cold trimmed direct GetCurrentMethod | 1 failed | 1 passed |
| Cold trimmed inlineable GetCurrentMethod | 1 failed | 1 passed |
| Trimmed targeted batch | 7 passed, 1 failed | 8 passed |
| Untrimmed R2R targeted batch | 8 passed, 1 failed | 9 passed |
| Full trimmed System.Runtime | 77,396 passed, 1 failed, 175 skipped |
77,397 passed, 0 failed, 175 skipped |
The affected-class fixed run also passed: 23 passed, 3 existing skips.
`CrossAssembly2` remains excluded when trimmed by dotnet/linker#2078 and
passes untrimmed; it is not counted as a trimmed pass.
Main test IL and main R2R images are byte-identical across each
original/fixed pair; skip sets are identical. Served assets were
verified against their respective rebuilt packs. This is a
matched-product A/B, not a native-module-only swap: CoreLib R2R image
bytes also differ.
### Existing reflection compatibility controls
`System.Reflection.Tests` caller-assembly theory, real cross-assembly
delegate invocation, static-constructor caller lookup,
executing-assembly lookup, and reflected first/second invocation all
pass: six cases on each original/fixed, trimmed/untrimmed browser R2R
configuration. Fresh-process delegate and reflective-invocation probes
also pass in all four configurations. All existing annotations remained
intact. These are compatibility controls, not failing-before
reproductions.
Full browser reflection suites have identical original/fixed results:
- Untrimmed: 1,750 passed, 1 failed, 23 skipped.
- Trimmed: 1,747 passed, 2 failed, 23 skipped.
Existing failures are `GetEntryAssembly` (browser host expectation
versus R2R expectation) and, trimmed only,
`AssemblyGetForwardedTypesLoadFailure` (underlying trimming cause not
isolated). Failure signatures and skip sets match before/after; neither
was suppressed.
Native arm64 Checked reflection control: six focused cases passed; full
suite 1,776 passed, 2 platform skips, zero failures.
## Remaining scope
Draft for review of the frame-lifecycle distinction and FCall exception.
Dedicated FCall cold/warm stack-identity coverage, a broader CoreCLR
GC-stress campaign, and other browsers have not been run. No performance
claim is made.
> [!NOTE]
> This change and pull request description were developed with GitHub
Copilot assistance.
Co-authored-by: Copilot App <[email protected]>1 parent 778255f commit a7fda7e
5 files changed
Lines changed: 99 additions & 13 deletions
File tree
- src
- coreclr/vm
- tests/Loader/classloader/DefaultInterfaceMethods/regressions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | 199 | | |
213 | 200 | | |
214 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| 303 | + | |
303 | 304 | | |
304 | 305 | | |
305 | 306 | | |
| |||
1397 | 1398 | | |
1398 | 1399 | | |
1399 | 1400 | | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
1400 | 1405 | | |
1401 | 1406 | | |
1402 | 1407 | | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
1403 | 1429 | | |
1404 | 1430 | | |
1405 | 1431 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2207 | 2207 | | |
2208 | 2208 | | |
2209 | 2209 | | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
2210 | 2219 | | |
2211 | 2220 | | |
2212 | 2221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2039 | 2039 | | |
2040 | 2040 | | |
2041 | 2041 | | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
2042 | 2049 | | |
2043 | 2050 | | |
2044 | 2051 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| 121 | + | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
124 | 181 | | |
125 | 182 | | |
126 | 183 | | |
| |||
0 commit comments