Skip ro segments which are not in range when walking heap for GC diagnostics #254
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed crash in gc_heap::walk_heap_per_heap when walking frozen segments
Motivation:
GC Heap diagnostics crashes after AssemblyLoadContext unloading with the following callstack
The issue can be reproduced with PerfView tool without Unity Editor enabling
COR_PRF_MONITOR_GCflag at startup - tool crashes on GC Heap dump of Unity Editor after we successfully unloaded an AssemblyLoadContext.I was suspecting heap corruption, but was not able to gather any proof. Comparison with gc::verify_heap yielded that heap verification uses heap_segment_in_range_p method to get the heap segment to iterate over. heap_segment_in_range_p checks that segment is not readonly/frozen (
heap_segment_flags_readonlyflag) or if it is “in range” (heap_segment_flags_inrangeflag).Changes:
It is a bit unclear to full extent what
USE_RANGESfeature do, however walking heap for diagnostics is different than Heap Verify functionality, so I suggest align segments walking strategy and ask upstream whether or not this is expected to be same or not.