[Gc] Win32: Multiple threads already spawned prior to GC_init? GC
Aborts due to unknown Thread!
Michael Paul Brandt
michael at pdc.dk
Thu Jan 3 14:23:21 PST 2008
We develop compilers and run-time systems for the Visual Prolog language
on Microsoft platforms. We have been using the Boehm-Demers-Weiser GC
for the past five years (currently v6.8) as part of our kernel runtime
Currently we are experiencing problems when running a Visual Prolog COM
component under Internet Information Server (IIS). Most likely because
the GC is called from an unknown thread.
The details are as follows:
The GC.lib is compiled with Visual Studio 2005 and flags
Threads are attached and detached using the DllMain callback. We have
programmed our own VIPGC_register_dynamic_libraries function that
minimizes the GC root set such that "foreign" data segments aren't
We develop Visual Prolog COM DLLs. These COM DLLs are accessed from
Microsoft Internet Information Server (IIS) using COM Interop from C#.
The IIS uses a worker process with numerous worker threads to invoke our
COM DLL. Upon Vip7Kernel.dll loading we immediately call GC_init, but
only the loading thread gets registered in GC's thread structure. Now,
at some stage another IIS worker thread decides to call some Visual
Prolog code using the COM DLL which results in a call to the GC. The GC
decides to do some housekeeping and starts the mark phase, which require
all thread stacks to be pushed onto the mark stack. The function
GC_push_all_stacks()of win32_threads.c is called and it pushes stacks
for all _registered_ threads and examines if current executing thread is
among the registered. If so, the variable found_me is set to true. The
function completes by verifying that found_me is indeed true or else it
if (!found_me) ABORT("Collecting from unknown thread.");
This is exactly what we experience in our embedded DLLs, since the
requesting thread has never been properly registered in the GC's thread
We have been through the GC mail archives and found no mentioning of
this thread issue. We have also reviewed the latest v7.0 code of the GC,
but this issue seems to remain a problem.
Would the proper solution (for us at least) be to enumerate all threads
of our process (using CreateToolhelp32Snapshot) and attach each
explicitly to the GC (right after GC_init is called)? Have anyone
encountered similar problems when embedding GC in "foreign" process
We appreciate all feedback. Thank you.
Prolog Development Center A/S
Tel. +45 36360000
Mail: michael.brandt at pdc.dk <mailto:michael.brandt at pdc.dk>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gc