www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - GC- and thread-related deadlock

reply klickverbot <see klickverbot.at> writes:
Hi all,

any idea why the following sample deadlocks on Linux x86_64?
(GDB stacktraces: http://gist.github.com/587964)

---
module test;

import core.thread;
import std.conv;
import std.range;
import std.string;

enum THREADS = iota(0, 9);
enum WORK_RANGE = iota(0, 30000);

void main() {
   Thread[] threads;

   // Invoke the threads.
   foreach (i; THREADS) {
     auto thread = new Thread(&run);
     threads ~= thread;
     thread.start();
   }

   // Wait for the threads to finish.
   foreach (i, thread; threads) {
     thread.join(true);
   }
}

void run() {
   foreach (i; WORK_RANGE) {
     string data = to!string(toStringz("Some random string which 
contains some random words."));
   }
}
Sep 20 2010
next sibling parent klickverbot <see klickverbot.at> writes:
Might possibly be related: 
http://d.puremagic.com/issues/show_bug.cgi?id=4890,
Sep 20 2010
prev sibling parent Sean Kelly <sean invisibleduck.org> writes:
klickverbot Wrote:

 Hi all,
 
 any idea why the following sample deadlocks on Linux x86_64?
 (GDB stacktraces: http://gist.github.com/587964)

Thanks for the stack trace! The cause wasn't immediately obvious so I've made a bunch of speculative changes to see if they fix the issue. Once I get a Linux VM set up here I'll see whether they've helped.
Sep 20 2010