www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6443] New: [GSoC] Catching exceptions in fibers broken on Windows

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6443

           Summary: [GSoC] Catching exceptions in fibers broken on Windows
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: code klickverbot.at



---
The following program crashes on Windows for me, while working as expected on
Linux and OS X:

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

void main() {
  (new Fiber({
    try {
      throw new Exception("Foo!");
    } catch (Exception e) {
      stderr.writefln("Caught: %s", e);
    }
  })).call();
}
---

DMD/druntime from Git master, running on Windows Server 2008 R2 x86_64 (inside
a VirtualBox VM, but that shouldn't matter). When building/debugging with
Visual D, I get a stack overflow in release mode (somewhere inside
KernelBase.dll), and a »Unhandled exception at 0x7547b9bc in ConsoleApp1.exe:
0xE0440001: 0xe0440001« in debug mode.

Since 0xe044001 is STATUS_DIGITAL_MARS_D_EXCEPTION, the obvious guess would be
that the fiber context switching code is somehow messing with SEH, so that the
exception is never actually caught. Unfortunately, I don't know enough about
the Win32 internals to be able to efficiently track this down.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 06 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6443




---
(the writefln() was only for demonstration purposes and is not needed in order
to trigger the bug)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6443


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[GSoC] Catching exceptions  |[GSoC] Catching exceptions
                   |in fibers broken on Windows |in fibers broken on
                   |                            |Windows/Linux x86_64



---
I unfortunately stand corrected: The snippet crashes on Linux x86_64 as well:
---

/lib/ld-linux-x86-64.so.2

/lib/ld-linux-x86-64.so.2













---

From the above trace, this seems to be a problem in the default backtrace
handler, and indeed, when I disable it by calling rt_setTraceHandler(0) (e.g.
from GDB), the program works as expected (on Windows, it crashes regardless of
whether the handler is enabled or not).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 10 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6443


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pszturmaj tlen.pl



---
*** Issue 6025 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 10 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6443


klickverbot <code klickverbot.at> changed:

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



---
Fixed in 2.056. Sean, do you really insist on not closing »your« bugs until the
release is out? Immediately closing them after the fix is in would reduce the
chance of bugs accidentally staying open, and help Walter compile the
changelog.

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