GC- and thread-related deadlock

klickverbot see at klickverbot.at
Mon Sep 20 07:23:44 PDT 2010


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."));
   }
}


More information about the Digitalmars-d mailing list