Home icon indicating copy to clipboard operation
Home copied to clipboard

Garbage Collection Heap Compaction bug

Open MateuszKlatecki opened this issue 7 years ago • 9 comments

When calling Debug.GC(true) (forcing garbage collection with heap compactation ) the execution stops with hard fault in some cases. I noticed this behavior on iMXRT1062 with custom application (about 11k lines of code). For now I cannot reproduce it with synthetic test app. If the GC is forced without the heap compactation it will perform GC without any issues.

As a temporary solution, we've disabled Heap Compaction globally by setting the NoCompaction flag during CLR startup.

MateuszKlatecki avatar Sep 25 '19 13:09 MateuszKlatecki

I've noticed the above when making that call right at the start of Program.Main(). If that same call is made further down when the execution has started it seems to work.

I don't have any explanation for the fact. The only thing that I could think of is that, for some reason, it requires the thread spawning to have started... But, then again, this could be just a coincidence....

josesimoes avatar Sep 25 '19 13:09 josesimoes

@MateuszKlatecki have you had the chance to test the above? If you can confirm that behaviour I think this can be closed as there is no (apparently) obvious cause for it.

josesimoes avatar Nov 14 '19 01:11 josesimoes

Hard fault ~ line 279 @ src\CLR\Core\GarbageCollector_ComputeReachabilityGraph.cpp

josesimoes avatar May 07 '20 02:05 josesimoes

@MateuszKlatecki this code executes on ExecuteGarbageCollection(). Are you forcing the GC execution or is it called regularly on your application execution?

josesimoes avatar May 07 '20 11:05 josesimoes

@josesimoes We are calling regularly GC every couple of seconds without forcing heap compaction.

This hardfault is very irregular. The "sub" pointer points to some odd location instead of managed heap.,

MicrosoftTeams-image

morali avatar May 07 '20 12:05 morali

May I ask why you're calling it?

josesimoes avatar May 07 '20 12:05 josesimoes

Yes, AFAIK there's no method of getting free memory, besides calling GC.

morali avatar May 08 '20 15:05 morali

Got you. So that's clearly a new feature. Please add that to the runtime API project as a suggestion.

josesimoes avatar May 08 '20 15:05 josesimoes

Closing this has it hasn't had any updates nor progresses.

josesimoes avatar Jul 09 '20 12:07 josesimoes