[Issue 4890] GC.collect() deadlocks multithreaded program.
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Sep 6 11:58:49 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=4890
--- Comment #25 from Sean Kelly <sean at invisibleduck.org> ---
Hrm... at one point thread_entryPoint called Thread.add to add itself, but I
think the add was moved to Thread.start at some point to deal with a race. I
had a comment in Thread.start explaining the rationale, but it looks like
Thread.start has been heavily edited and the comment is gone. Either way,
having Thread.start call Thread.add *after* pthread_create is totally wrong, as
it leaves a window for the thread to exist and be allocating memory but be
unknown to the GC.
I think I'll have to roll back thread.d to find my original comments and see
how it used to be implemented. Something was clearly changed here, but there's
no longer enough info to tell exactly what.
I've got to say that seeing these and other changes in core.thread without
careful documentation of what was changed and why it was done is very
frustrating. There's simply no way to unit test for the existence or lack of
deadlocks, and the comments in this module were built up over years of bug
fixes to explain each situation and why the code was the way it was. If
someone changes the code in this module they *must* be absolutely sure of what
they are doing and document accordingly.
--
More information about the Digitalmars-d-bugs
mailing list