Bug 5537 – invariant._d_invariant() failing in std.concurrency.MessageBox.get
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2011-02-06T20:32:00Z
Last change time
2015-06-09T01:31:20Z
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2011-02-06T20:32:06Z
This program currently results in a segfault:
import std.concurrency;
import std.stdio;
void main()
{
int currThreads = 0;
enum maxThreads = 6;
size_t totalThreads = 0;
auto recProc = (Tid tid)
{
writeln(++totalThreads);
};
for(size_t i = 0; i < 1_000; ++i)
{
if(currThreads < maxThreads)
receiveTimeout(1, recProc);
else
receive(recProc);
spawn(&threadFunc, thisTid);
}
while(currThreads > 0)
receive(recProc);
}
void threadFunc(Tid parentTid)
{
send(parentTid, thisTid);
}
This is using the latest versions of druntime and phobos from git. The stack trace I get with gdb is
#0 0x080ade03 in invariant._d_invariant() ()
#1 0x080a56cc in std.concurrency.MessageBox.get!(long,void delegate(Tid tid)).get (this=0x0, _param_1=579319349254397504, _param_0=10000) at /home/jmdavis/dmd2/linux/bin/../../src/phobos/std/concurrency.d:716
#2 0x080a56aa in std.concurrency.receiveTimeout!(void delegate(Tid tid)).receiveTimeout (_param_1=579319349254397504, ms=1) at /home/jmdavis/dmd2/linux/bin/../../src/phobos/std/concurrency.d:501
#3 0x080a27a5 in D main () at l.d:18
#4 0x080add86 in rt.dmain2.main() ()
#5 0x080add18 in rt.dmain2.main() ()
#6 0x080addca in rt.dmain2.main() ()
#7 0x080add18 in rt.dmain2.main() ()
#8 0x080adcc4 in main ()
If I simplify the program that it uses only receive and not receiveTimeout, it still fails, so it's not an issue specific to receiveTimeout. I have also confirmed that the check-in 94bd4f661be79db34faedf76ca139115a07a9dd3 (Issue 4307 - spawn()'ed thread doesn't terminate) didn't cause the problem.
I have no idea what invariant._d_invariant() is - std.concurrency doesn't have any invariants in it - but this bug makes spawn utterly useless.