Thread overview
[Issue 1126] New: multithreading breaks phobos exceptions on mingw/gdc .23
Apr 11, 2007
d-bugmail
Apr 27, 2007
Matt Brandt
Sep 07, 2012
Iain Buclaw
April 11, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1126

           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); }
  writefln("Returning");
}

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

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.


-- 

April 27, 2007
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 threads.

Matt

September 07, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=1126


Iain Buclaw <ibuclaw@ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #1 from Iain Buclaw <ibuclaw@ubuntu.com> 2012-09-07 02:44:09 PDT ---
Seems to be correct as of testing the sample on D2.


----
import std.stdio, core.thread, std.socket;

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

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

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