Every critical section initialized inside of Wine should have the debug string set. It's printed in the debug message on deadlock and thus makes bug reports containing such output more useful.

Example for static critical section:

static CRITICAL_SECTION foo_cs;
static CRITICAL_SECTION_DEBUG foo_cs_debug =
    0, 0, &foo_cs,
    { &foo_cs_debug.ProcessLocksList,
      &foo_cs_debug.ProcessLocksList },
    0, 0, { (DWORD_PTR)(__FILE__ ": foo_cs") }
static CRITICAL_SECTION foo_cs = { &foo_cs_debug, -1, 0, 0, 0, 0 };

Example for dynamic critical section:

if (name.DebugInfo) name.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": cs");

Don't forget to unset the debug info before deleting the critical section:

if (name.DebugInfo) name.DebugInfo->Spare[0] = 0;

There are various variations for the init and delete functions and for the data type (though all locatable by the strings CRITICAL_SECTION and CriticalSection).

Critical section initialisation may fail to create the debug info in low memory situations. Therefore we should check that the returned debug info is non-NULL before accessing it.

grep -r DebugInfo . | grep Spare

Will find all the places in the source that need to be checked.


ToDo: Make a script for Smatch (or something similar) that checks, that critical sections in wine have a debug string set (probably containing __FILE__), that DeleteCriticalSection is not used on a statically initialized one and that all dynamically initialized ones have a DeleteCriticalSection ( possibly by extending ).

Not checked: Peb and Syslevel related things, dlls/kernel/syslevel.c , dlls/kernel/pthread.c

Workers: JanZerebecki


CriticalSectionDebugInfo (last edited 2008-06-20 04:07:49 by JonGriffiths)