8

I am debugging a GC heap corruption and came to the step where I want to try running the program under WinDbg + PageHeap + AppVerifier + GCStress.

I found in the article Software crash: faulting module mscorwks.dll, version 1.1.4322.2379 that I can enable GCStress like this:

reg.exe add "HKLM\SOFTWARE\Microsoft\.NETFramework" /f  /v HeapVerify  /t REG_DWORD  /d 1  
reg.exe add "HKLM\SOFTWARE\Microsoft\.NETFramework" /f  /v StressLog  /t REG_DWORD  /d 1  
reg.exe add "HKLM\SOFTWARE\Microsoft\.NETFramework" /f  /v GCStress  /t REG_DWORD  /d 3  
reg.exe add "HKLM\SOFTWARE\Microsoft\.NETFramework" /f  /v FastGcStress  /t REG_DWORD  /d 2

(I am trying this method. It takes the program forever to launch. I deleted the last two entries from the registry to have it work, probably something is wrong with the approach itself.)

Or the article Access Violation in .NET 4 Runtime in gc_heap::garbage_collect with no unmanaged modules described the other method:

(DWORD) StressLog = 1  
(DWORD) LogFacility = 0xffffffff  
(DWORD) StressLogSize = 65536

Which way is correct or is there another correct way?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
net_prog
  • 9,921
  • 16
  • 55
  • 70
  • I don't understand the question. You are asking how to turn it on, then say that you found you can enable it with the first method, but that doesn't work. Does the second method work? – Kieren Johnstone Oct 26 '11 at 12:12
  • @KierenJohnstone, I didn't try the second method and I am not sure if either of these is correct. That is all I found over the web about GCStress and I would like people proficient in the subject to advise. I wrote that the first method is slow because I may think that probably it could be made faster by setting other values for the specified registry keys. – net_prog Oct 27 '11 at 08:43

1 Answers1

0

I searched GCStress on Koders. It turned out the best way to understand it is by looking at .NET's source code:

enum  GCStressFlags {
    GCSTRESS_NONE               = 0,
    GCSTRESS_ALLOC              = 1,    // GC on all allocations and 'easy' places
    GCSTRESS_TRANSITION         = 2,    // GC on transitions to preemtive GC
    GCSTRESS_INSTR_JIT          = 4,    // GC on every allowable JITed instruction
    GCSTRESS_INSTR_NGEN         = 8,    // GC on every allowable NGEN instruction
    GCSTRESS_UNIQUE             = 16,   // GC only on a unique stack trace
};
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
kizzx2
  • 18,775
  • 14
  • 76
  • 83