Skip to content

DAC fails to enumerate heap objects on .NET 7+ due to GC Regions  #96568

Closed

Description

@asundheim

Description

During heap object walking via ICorDebugHeapEnum::Next, DacHeapWalker::MoveToNextObject() fails to properly get the current segment / generation, causing it to skip calling GetSegmentAndAllocRange() for gen0 objects, so if it ends up in a dead area, it won't get itself back out and will fail to return objects to the enumerator.

SOS says the object under inspection is gen0, but when stopped on the access violation from DacHeapWalker::GetSize the check isGen0 in MoveToNextObject claims it's gen2, causing it not to call GetSegmentAndAllocRange()
image

Reproduction Steps

Known repros on clr versions 7.0.1423.51910, 8.0.23.53103. Setting DOTNET_GCRegionSize to a small value should increase the likelihood that even a template app can trigger the issue.

Expected behavior

Objects are returned via the enumerator.

Actual behavior

Enumerator gets stuck, and no further progress can be made.

Regression?

Seems to be only the latest versions of the runtime, heap walking has not had this issue before.

Known Workarounds

No response

Configuration

No response

Other information

DacHeapWalker::MoveToNextObject()

Activity

  1. ghost added
    needs-area-label
    on Jan 5, 2024
  2. ghost added
    untriaged
    on Jan 5, 2024
  3. asundheim commented on Jan 5, 2024

    @asundheim
    Author
  4. added and removed
    needs-area-label
    on Jan 7, 2024
  5. tommcdon commented on Jan 7, 2024

    @tommcdon
    Member
  6. added this to the 9.0.0 milestone on Jan 8, 2024
  7. ghost removed
    untriaged
    on Jan 8, 2024
  8. cshung commented on Jan 8, 2024

    @cshung
    Contributor

    @asundheim, it looks like you have gone through some debugging and have already found out the root cause, would you mind helping us to get it fixed?

  9. asundheim commented on Jan 8, 2024

    @asundheim
    Author

    @asundheim, it looks like you have gone through some debugging and have already found out the root cause, would you mind helping us to get it fixed?

    I'd be happy to help, or at the very least test out a fix, but I'm at a loss for what has actually changed to cause this.

  10. ghost added
    in-pr
    on Jan 8, 2024
  11. ghost removed
    in-pr
    on Jan 11, 2024
  12. locked and limited conversation to collaborators on Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions