Bug 2404 – std.gc.fullCollect hangs with multiple threads.

Status
RESOLVED
Resolution
DUPLICATE
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-10-09T04:00:00Z
Last change time
2015-06-09T01:20:16Z
Assigned to
bugzilla
Creator
sludwig

Comments

Comment #0 by sludwig — 2008-10-09T04:00:52Z
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. The ftp-server seems not to be available currently, so I am not able to check if this is a regression from 2.018 or earlier. 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).
Comment #1 by sludwig — 2008-10-21T02:03:40Z
*** This bug has been marked as a duplicate of 2405 ***