-
Couldn't load subscription status.
- Fork 5.2k
Skip ro segments which are not in range when walking heap for GC diagnostics #100002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip ro segments which are not in range when walking heap for GC diagnostics #100002
Conversation
|
Tagging subscribers to this area: @dotnet/gc |
|
@dotnet-policy-service agree company="Unity Technologies" |
|
cc @cshung
We currently never unregister/remove such segments and never put stuff from unloadable ALCs there 🤔 |
thanks! ok, then my understanding was wrong and perhaps we do have segments corruption or there is another mechanism that may unmark segments |
|
@alexey-zakharov, is the crash something you can share with us a repro? |
@cshung yes, I think so - do you know what are the guidelines for sharing? |
Thanks for planning to share! I don't think we have guidelines for sharing repro, but we have a template for opening bug issues and there are some general questions that you can answer there. https://github.com/dotnet/runtime/issues/new?assignees=&labels=&projects=&template=01_bug_report.yml |
|
Is this superseded by #100444 ? |
yes, I've dug deeper into the issue and we've figured a better fix |
|
(the real issue we had was that SzArray of a collectible type was allocated on a frozen heap and once LoaderAllocator gets destroyed object's MethodTable points to a bad memory which leads to random consequences when iterating heap) |
Fixed crash in gc_heap::walk_heap_per_heap when walking frozen segments
Motivation:
Enabling
COR_PRF_MONITOR_GCGC Heap diagnostics flag causes crash after initiating AssemblyLoadContext unloading with the following callstack.I was suspecting invalid profiler setup, however the issue was also reproducible with PerfView tool without enabling
COR_PRF_MONITOR_GCflag via profiler dll at startup - tool crashes on GC Heap dump once one of assemblies from AssemblyLoadContext gets unloaded.I was suspecting then heap corruption, but was not able to gather any proof of that by running
gc::verify_heapevery GC and native/managed transition (the latter was painfully slow 😁). Further comparison withgc::verify_heapyielded that heap verification usesheap_segment_in_range/heap_segment_next_in_rangemethods to get the heap segment to iterate over.heap_segment_in_rangechecks that segment is not readonly/frozen (heap_segment_flags_readonlyflag) or if it is “in range” (heap_segment_flags_inrangeflag). At the same timegc_heap::walk_heap_per_heapscans through all segments.Changes:
My hypothesis is that assembly unloading may free/rollback segments that are used for string/type/etc data in frozen segments and thus we need to skip such segments when traversing heap for diagnostics. I might be wrong given my limited understanding of
USE_RANGESfeature and would appreciate other ideas 😄