Uh oh!
There was an error while loading. Please reload this page.
[cDAC] Read WKS card table from preserved VM global - #132938
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9a58113d-e1d8-4ed2-9113-9f1de69cd49e
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 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: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Review tier: Lite
Findings: None
What changed in this PR
This PR updates the cDAC GC workstation heap contract to treat the GCHeapCardTable global slot as optional when the slot’s target memory can’t be read, returning a null card table pointer while still providing valid heap and generation data.
Changes:
- Make
GCHeapWKS.CardTableresilient to an unreadable card-table slot by usingTryReadPointerand falling back toTargetPointer.Null. - Relax DEBUG cross-validation in
SOSDacImpl.GetGCHeapStaticDatato tolerate a zero card table when the legacy DAC still reports a non-zero value. - Add unit test coverage for both readable and unreadable card-table slot scenarios, including validating
GetGCHeapStaticDataoutput.
| File | Description |
|---|---|
| src/native/managed/cdac/tests/UnitTests/GCTests.cs | Adds tests for readable vs unreadable workstation card-table slot, and validates GetGCHeapStaticData returns a null card table without breaking generation data. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs | Narrows DEBUG-only cross-validation to allow card_table == 0 for reduced-dump scenarios in GetGCHeapStaticData. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/GC/GCHeapWKS.cs | Switches card-table read to TryReadPointer with a TargetPointer.Null fallback to tolerate unreadable target memory. |
rcj1
commented
Aug 30, 2026
I don't think this is the root cause of the issue; rather, we are trying to read memory at gc_heap::card_table which we do not preserve in a dump. |
steveisok
commented
Aug 30, 2026
I don't think this is the root cause of the issue; rather, we are trying to read memory at gc_heap::card_table which we do not preserve in a dump. Making sure I'm following you - Are you suggesting this PR should remap |
rcj1
commented
Aug 30, 2026
Yes, I think that is the best solution. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9a58113d-e1d8-4ed2-9113-9f1de69cd49e
jkotas
commented
Aug 31, 2026
Why is the card_table needed in the first place?
This suggests that the fix is not quite right. |
steveisok
commented
Aug 31, 2026
From my read it's Are you suggesting we report 0 for this? |
max-charlamb
commented
Aug 31, 2026
This is exposed by I would prefer not to map this value to the runtime copy (this seems like it would not fix the issue if using a standalone GC), but instead fix dump collection to make sure this value is enumerated. |
jkotas
commented
Aug 31, 2026
How is this exposed by this API? This API walks linked list starting at BookkeepingStart: runtime/docs/design/datacontracts/GC.md Lines 948 to 979 in b5388ad |
rcj1
commented
Aug 31, 2026
|
max-charlamb
commented
Aug 31, 2026
You are right, I misread the function. CLRMD does expose this through |
rcj1
commented
Aug 31, 2026
Fwiw it doesn’t look like we use this card table value in the three consumers I checked. |
I would expect the card table pointer to be included in the dump with the rest of |
max-charlamb
commented
Aug 31, 2026
I created a draft PR to fix this from the enumeration side. The DAC previously explicitly enumerated the static WKS GC values for everything besides the card_table. Adding this would be a minor gc/dac interface bump. I'm fine with either fix. If we go forwards with the datadescriptor sided fix (in this PR), we should leave a note to undo it when we switch over to using the cDAC to enumerate memory. |
steveisok
commented
Aug 31, 2026
I think we need to test the draft PR runtime with CDB and see if it fixes the problem. If it doesn't / we can't somehow fix it, then I think this a short term fix and as you said, we remove it once we switch over. |
noahfalk
commented
Aug 31, 2026
+1 for that version of the fix (assuming we confirm it works, it seems like it should) |
steveisok
commented
Sep 1, 2026
I generated a dump w/ cdb and #132973 and read it with cdac. While the card table read was fixed, it exposed a failure on the next read where
Given the cdac reader is eager, we probably should enumerate the full WKS diagnostics arrays. |
max-charlamb
commented
Sep 1, 2026
I updated #132973 to also enumerate those arrays. Previously the DAC did not support I have tested the single file scenario as described in this PR description and the cDAC and DAC are both able to read the heap dumps and support |
steveisok
commented
Sep 1, 2026
@max-charlamb I tested against your PR and it looks good. I'll close this in favor of yours. |
Windows CDB
/mwsingle-file dumps preserve the VMg_card_tableglobal but can omit the workstation GC'sgc_heap::card_tableslot. MapGCHeapCardTableto the preserved VM global in CoreCLR's embedded WKS descriptor so cDAC can return the actual card-table value and continue reading heap data.The standalone GC descriptor continues using
gc_heap::card_tablebecause it cannot depend on VM state.Tests: CoreCLR Release and Debug builds; cDAC
GCTests; focused workstation GC dump test.Note
This pull request description was generated with GitHub Copilot.