[Issue 11981] unittest 'host' deadlock
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 8 16:34:23 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11981
Stanislav Blinov <stanislav.blinov at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |stanislav.blinov at gmail.com
--- Comment #2 from Stanislav Blinov <stanislav.blinov at gmail.com> 2014-02-08 16:33:53 PST ---
Don't know how useful this could be but...
This code:
import std.concurrency;
import core.memory;
import core.thread;
import core.atomic;
import std.stdio;
// Reduced from host unittest
version(all) // version(none) avoids deadlock
{
shared uint tctor, tdtor;
static this() { auto v = atomicOp!"+="(tctor,1); writefln(" new thread %s",
v); }
static ~this() { auto v = atomicOp!"+="(tdtor,1); writefln(" cleanup %s", v);
}
}
void main()
{
enum uint numThreads = 16;
long i = 0;
while(true)
{
writefln("Starting run %s", i);
shared uint finished;
foreach(immutable t; 0..numThreads)
{
spawn((shared uint* f) { atomicOp!"+="(*f, 1); }, &finished);
}
long n = 0;
while (atomicLoad!(MemoryOrder.acq)(finished) != numThreads)
{
writefln("suspend %s", n);
thread_suspendAll();
writefln("resume %s", n);
thread_resumeAll();
++n;
}
thread_joinAll();
writefln("Run %s done", i);
++i;
}
}
deadlocks in every single run on my machine (though randomly in each run).
$uname -a
Linux 3.8.0-26-generic #38-Ubuntu SMP Mon Jun 17 21:43:33 UTC 2013 x86_64
x86_64 x86_64 GNU/Linux
$ldd --version
ldd (Ubuntu EGLIBC 2.17-0ubuntu5.1) 2.17
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list