[Gc] Re: Win32: Deadlock if DEBUG_THREADS

Ivan Maidanski ivmai at mail.ru
Thu Nov 5 12:27:37 PST 2009

An hour ago I wrote:
> 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

It's easier to reproduce it with -DPARALLEL_MARK (with or w/o -DDONT_USE_SIGNALANDWAIT).

> 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(),...

Not in WriteFile(), in EnterCriticalSection() in GC_write().

> ... 1 thread is waiting for a system resource in CreateThread() and the backtrace for the main thread is not visible).

The main thread is in GC_write acquiring GC_write_cs too.

> 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?

(Removing GC_write_cs doesn't solve anything...)


More information about the Gc mailing list