[Issue 8774] 2.059 worked 2.060 does not: Unable to join thread

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 25 04:42:36 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #13 from luka8088 <luka8088 at owave.net> 2012-12-25 04:42:33 PST ---
(In reply to comment #10)
> (In reply to comment #8)
> > Here is a simple test case:
> > 
> > -----
> > 
> > module program;
> > 
> > import std.stdio;
> > import core.thread;
> > 
> > void main () {
> > 
> >   Thread t1, t2;
> > 
> >   t1 = new Thread(delegate { t2.start(); });
> >   t2 = new Thread(delegate { Thread.sleep(dur!"seconds"(1)); });
> > 
> >   t1.start();
> >   t2.join();
> > 
> > }
> > 
> > -----
> > 
> > http://dpaste.dzfl.pl/0d24dd06
> > 
> > output:
> >   core.thread.ThreadException at src/core/thread.d(780): Unable to join thread
> > 
> > if t2.join occurs after t2 already finished then exception is not thrown, hence
> > the sleep
> 
> This one is a genuine race condition: t2.join could be called before t2 is
> actually started by t1. And as far as I can tell this is the *most* *probable*
> outcome. So it can't be seriously taken as test case without proper
> synchronization between threads.
> 
> What it shows though is that you can't join a thread that isn't started and the
> error is "Unable to join thread".


Yes, you are correct, it does not make much sense, but there is another issue.
The following code throws an exception on 64-bit linux (32-bit linux and 32-bit
windows executes without throwing an exception). On 64-bit linux t2 is never
started.

-----

module program;

import std.stdio;
import core.thread;

void main () {

  Thread t1, t2;
  bool runned = false;

  t1 = new Thread(delegate { t2.start(); });
  t2 = new Thread(delegate { runned = true; });

  t1.start();
  Thread.sleep(dur!"seconds"(1));
  assert(runned);

}

-----

http://dpaste.dzfl.pl/5dc9733e


Should I file a new bug report ?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list