Bug 7074 – std.concurrency.receive segfaults when called from new thread
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-12-06T12:25:00Z
Last change time
2015-04-28T01:15:00Z
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2011-12-06T12:25:18Z
Not sure if this is expected:
---
import core.thread;
import std.concurrency;
void main() {
(new Thread({receive((bool b){});})).start();
}
---
crashes using Phobos c83edad (2.057 beta), because the mbox of the newly created thread has not been initialized yet (it is for the main thread in a shared static constructor, and by spawn() for threads created by it).
Workaround: Force initialization of mbox by calling std.concurrency.thisTid on the new thread first.
Comment #1 by ratchet.freak — 2012-10-08T11:07:31Z
fix: use thisTid in recieve instead of accessing mbox directly
Comment #2 by david — 2015-04-11T02:07:18Z
In 2.067 this code asserts with the following message:
core.exception.AssertError@/usr/include/dlang/dmd/std/concurrency.d(671): Cannot receive a message until a thread was spawned or thisTid was passed to a running thread.
It appears this can be closed.