[Gc] Win32: Deadlock if DEBUG_THREADS

Ivan Maidanski ivmai at mail.ru
Thu Nov 5 11:35:54 PST 2009


Hi!

Today I ran into a deadlock on Win32 with DEBUG_THREADS defined.
The simplest config to reproduce is (for MinGW, for VC++ is similar):
 gcc -DALL_INTERIOR_POINTERS -DGC_THREADS -DDEBUG_THREADS -g [-DGC_ASSERTIONS] -I include -I libatomic_ops/src tests/test.c *.c -luser32

The deadlock occurs at least in 1/5 runs. Not observed if set GC_DISABLE_INCREMENTAL=1. Doesn't depend on GC_USE_GETWRITEWATCH value (0/1).

At present, I've failed to found out the place of the problem (I observe 3 threads waiting for alloc lock in GC_malloc, 2 threads are waiting for some system resource in WriteFile(), 1 thread is waiting for a system resource in CreateThread() and the backtrace for the main thread is not visible).

BTW. What's the purpose of GC_write_cs (beyond atomicity of in-line writes)? And why do we need to acquire it in GC_stop_world?

Bye.


More information about the Gc mailing list