www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Issue 1126] New: multithreading breaks phobos exceptions on mingw/gdc .23

reply d-bugmail puremagic.com writes:

           Summary: multithreading breaks phobos exceptions on mingw/gdc .23
           Product: DGCC aka GDC
           Version: unspecified
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn users.sf.net
        ReportedBy: default_357-line yahoo.de

Consider the following code:
import std.stdio, std.thread, std.socket;

// intended to fail
void cause_throw() {
  Socket s=new TcpSocket(new InternetAddress("bogus", 80));

void main() {
  (new Thread(() { while (true) { } return 0; })).start;
  try cause_throw;
  catch (Exception e) { writefln("Exception: ", e); }

Now, if I comment the thread out, I get, as expected:
Exception: Unable to resolve etc.

However, if I leave it as it is, I get "Error: Unable to resolve etc.", and the
program freezes.

I was unable to find another gdc/mingw user to verify it.
Tried on a virgin 3.4.5/.23 and .22 and on a 4.0.2/.23 gdc MinGW setup.
The problem seems to be specific to gdc/win32.

Apr 11 2007
parent Matt Brandt <justmattb walkingdog.net> writes:
I have also seen behavior like this on GDC 0.22 and GDC 0.23 for powerpc-linux.
If exceptions occur in multiple threads sometimes I lose one of the threads
with no coredump, even if all of the exceptions are caught by the program code.
I think this must be a fundamental problem with Phobos exception handling and

Apr 27 2007