October 15, 2004
Why you should never call Suspend/TerminateThread (Part III)
For all people who still belive that calling SuspendThread or TerminateThread is not so bad, I want to show that in an simple win32 app, we already have *19* critical sections which might produce an deadlock if you call these function in the wrong time.
Here is the ouput of windbg on an empty win32-console app:
0:000> !locks -v CritSec ntdll!RtlCriticalSectionLock+0 at 7C98C0A0 CritSec ntdll!DeferedCriticalSection+0 at 7C98C080 CritSec ntdll!LdrpLoaderLock+0 at 7C98C0D8 CritSec ntdll!FastPebLock+0 at 7C98E4C0 CritSec ntdll!RtlpCalloutEntryLock+0 at 7C98E4A0 CritSec ntdll!PMCritSect+0 at 7C98DE40 CritSec ntdll!UMLogCritSect+0 at 7C98DE20 CritSec ntdll!RtlpProcessHeapsListLock+0 at 7C98C2E0 CritSec +140608 at 00140608 CritSec +240608 at 00240608 CritSec +250608 at 00250608 CritSec kernel32!BaseDllDirectoryLock+0 at 7C883700 CritSec kernel32!BaseDllRegistryCache+18 at 7C883078 CritSec kernel32!gcsNlsProcessCache+0 at 7C883740 CritSec kernel32!gcsTblPtrs+0 at 7C883360 CritSec kernel32!DllLock+0 at 7C8836A0 CritSec kernel32!ExeNameCriticalSection+0 at 7C8833C0 CritSec kernel32!gcsAppCert+0 at 7C883860 CritSec kernel32!gcsAppCompat+0 at 7C8837A0 Scanned 19 critical sections
Posted 3 years, 4 months ago on October 15, 2004
The trackback url for this post is http://blog.kalmbachnet.de/bblog/trackback.php/17/
The trackback url for this post is http://blog.kalmbachnet.de/bblog/trackback.php/17/
Comments have now been turned off for this post