Commit a4e4aee
[cDAC] Use NativeCodeVersion entry for GetMethodVarInfo offset (#128154)
> [!NOTE]
> This PR was authored with assistance from GitHub Copilot.
## Problem
`runtime-diagnostics` build
[1418267](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1418267)
failed with:
```
Process terminated. Assertion failed.
GetNumLocations cDAC: 0, DAC: 1
at Microsoft.Diagnostics.DataContractReader.Legacy.ClrDataValue...GetNumLocations(UInt32*)
```
The asserting frame was the `this` parameter of
`ManualResetEventSlim.Wait` during `!ClrStack -a` against the WebApp3
dump.
## Root cause
`DebugInfo_2.GetMethodVarInfo` computed the IP -> codeOffset relative to
`MethodDesc.NativeCode`. That field tracks only the most
recently-compiled tier. With tiered compilation, an older-tier frame
still on the stack gets the wrong base, no `varInfo` ranges match, and
cDAC returns an empty location list while the legacy DAC finds the
entry.
The legacy DAC (`src/coreclr/debug/daccess/daccess.cpp:5591`) instead
uses `ExecutionManager::GetNativeCodeVersion(address).GetNativeCode()`
-- the entry point of the specific NativeCodeVersion that owns the IP.
This bug has been latent since #125463. dotnet/diagnostics#5767 (merged
2026-05-12) rebuilt the debuggees with the .NET 11 test SDK, which
increased the chance of hot methods like `ManualResetEventSlim.Wait`
straddling tier boundaries at dump-capture time and surfaced the
existing bug.
## Fix
Resolve the IP-specific `NativeCodeVersion` via the `ICodeVersions`
contract (already mirrors `ExecutionManager::GetNativeCodeVersion` +
`NativeCodeVersion::GetNativeCode` for versionable and non-versionable
methods). Throw on an invalid `NativeCodeVersion`, matching the native
DAC's `E_INVALIDARG` behavior.
### Type-correctness fix (uncovered while debugging an ARM32 regression)
While validating the fix above, an ARM32 regression in
`IXCLRDataValueDumpTests.GetSize_ReturnsExpectedSizes` revealed a
long-standing mistype:
- `IExecutionManager.GetStartAddress` / `GetFuncletStartAddress`
declared `TargetCodePointer`, but the value stored in `CodeBlock` is the
raw code-block start with no ARM32 thumb bit. That matches native --
`EECodeInfo::GetStartAddress` and `CodeHeader::GetCodeStartAddress` both
return `TADDR` -- but the cdac type signature was lying about what the
value represented.
- On ARM32, `CodeVersions_1.GetSpecificNativeCodeVersion` compared
`MethodDesc.NativeCode` (a `PCODE` with the thumb bit set) against the
raw `TADDR` from `GetStartAddress`, so the equality check never matched
and `GetNativeCodeVersionForIP` returned `Invalid` -- which broke the
new `GetMethodVarInfo` path on ARM32.
The first commit in this PR changes the return types to `TargetPointer`
(matching native `TADDR` semantics), drops the now-redundant
`AddressFromCodePointer` conversions at the callers, and at the one site
that genuinely needs a `PCODE` for comparison uses
`CodePointerFromAddress` (the cdac analogue of native `PINSTRToPCODE`).
The second commit is the original `GetMethodVarInfo` change, now safe on
ARM32.
## Validation
- Built cdac Contracts and Legacy projects: clean.
- `dotnet test` on the full cdac suite: 2133/2133 passed (16 unrelated
skips).
- runtime-diagnostics CI will validate end-to-end behavior on x64 and
ARM32.
---------
Co-authored-by: Max Charlamb <maxcharlamb@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent ce5ff45 commit a4e4aee
12 files changed
Lines changed: 46 additions & 34 deletions
File tree
- docs/design/datacontracts
- src/native/managed/cdac
- Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts
- Microsoft.Diagnostics.DataContractReader.Contracts/Contracts
- DebugInfo
- ExecutionManager
- StackWalk/Context/X86
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| 257 | + | |
257 | 258 | | |
258 | 259 | | |
259 | 260 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
| 100 | + | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
142 | 144 | | |
143 | 145 | | |
144 | 146 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
| 42 | + | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
Lines changed: 9 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
| 49 | + | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
55 | | - | |
| 59 | + | |
| 60 | + | |
56 | 61 | | |
57 | 62 | | |
58 | 63 | | |
| |||
62 | 67 | | |
63 | 68 | | |
64 | 69 | | |
65 | | - | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
| |||
336 | 341 | | |
337 | 342 | | |
338 | 343 | | |
339 | | - | |
| 344 | + | |
340 | 345 | | |
341 | 346 | | |
342 | 347 | | |
| |||
Lines changed: 8 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
| 238 | + | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
322 | | - | |
323 | | - | |
| 322 | + | |
| 323 | + | |
324 | 324 | | |
325 | 325 | | |
326 | | - | |
327 | | - | |
| 326 | + | |
328 | 327 | | |
329 | 328 | | |
330 | 329 | | |
| |||
337 | 336 | | |
338 | 337 | | |
339 | 338 | | |
340 | | - | |
| 339 | + | |
341 | 340 | | |
342 | 341 | | |
343 | 342 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
0 commit comments