[Issue 2405] New: std.gc.fullCollect hangs with multiple threads.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 9 02:28:10 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2405

           Summary: std.gc.fullCollect hangs with multiple threads.
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: ludwig at informatik.uni-luebeck.de


A bit difficult to debug using the existing debuggers - but when another
background thread is active in addition to the main thread, the main thread
seems to pause or deadlock itself when fullCollect is called (implicitly or
explicitly). This makes threaded programming almost impossible atm and is a
complete blocker for me.

This is a regression from 2.018. Not tested on Linux.

The following test code reproduces the problem 100% of the time on my dual-core
system:
---
import std.gc;
import std.stdio;
import std.thread;
import std.c.windows.windows;

int main()
{
        (new Thread(delegate int(){
                Sleep(500); // simulate some work
                return 0;
        })).start();

        writeln("Running fullCollect..");
        std.gc.fullCollect();
        writeln(".. done");

        assert(false, "Did not hang!");

        return 0;
}
---


The stack trace for the main thread looks like this during the hang:
---
#0 ?? () from ntdll.dll
#1 0x004bf44e in void std.thread.Thread.pause(void*) () from thread
#2 0x005295c2 in uint gcx.Gcx.fullcollect(void*, void*) () from gcx
#3 0x0051b140 in void gcx.GC.fullCollect(void*) () from gcx
#4 0x004bf013 in void std.gc.fullCollect() () from gc
#5 0x004bef4c in _main () from dmain2
#6 0x0053a211 in _mainCRTStartup () from constart
#7 0x7d4e992a in ?? () from KERNEL32.dll
---

Sidenote:
There seems to be another issue with concurrent allocations/frees which has
proven itself to be hard to reproduce in a testcase (might be
http://d.puremagic.com/issues/show_bug.cgi?id=1957).


-- 



More information about the Digitalmars-d-bugs mailing list