[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. |
|
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. |
|
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 |
|
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
|
Why is the card_table needed in the first place?
This suggests that the fix is not quite right. |
From my read it's Are you suggesting we report 0 for this? |
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. |
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 |
|
You are right, I misread the function. CLRMD does expose this through |
|
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 |
|
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. |
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. |
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.