www.digitalmars.com         C & C++   DMDScript  

D.gnu - Can't catch Phobos exceptions

reply "Demetri" <Supernova2003dh yahoo.com> writes:
I wrote a small D program. When compiled with DMD, it works fine, 
but neither GDC nor LDC2 can catch exceptions thrown from Phobos 
(proven by GDB). How do I fix this?

Example code:

     import std.process;
     void main(){
       try
       {
         spawnProcess(["/dev/null"]);
       }
       catch (Throwable p)
       {
         return;
       }
     }

which dies with SIGABRT when compiled and executed, even though 
the catch block should catch the ProcessException.

Compiler: ldc2 based on LLVM 3.3 and DMD 2.063.2 (invoked via 
ldmd2 -O -inline -release), but also happens with gdc 4.8.2 
(invoked via gdmd -O -inline -release). The execption is caught 
when I use dmd -O -inline -release to compile, even when I only 
catch ProcessException and not Throwable.
Mar 17 2014
next sibling parent Iain Buclaw <ibuclaw gdcproject.org> writes:
On 17 March 2014 18:13, Demetri <Supernova2003dh yahoo.com> wrote:
 I wrote a small D program. When compiled with DMD, it works fine, but
 neither GDC nor LDC2 can catch exceptions thrown from Phobos (proven by
 GDB). How do I fix this?

 Example code:

     import std.process;
     void main(){
       try
       {
         spawnProcess(["/dev/null"]);
       }
       catch (Throwable p)
       {
         return;
       }
     }

 which dies with SIGABRT when compiled and executed, even though the catch
 block should catch the ProcessException.

 Compiler: ldc2 based on LLVM 3.3 and DMD 2.063.2 (invoked via ldmd2 -O
 -inline -release), but also happens with gdc 4.8.2 (invoked via gdmd -O
 -inline -release). The execption is caught when I use dmd -O -inline
 -release to compile, even when I only catch ProcessException and not
 Throwable.

SIGABRT is normally a sign of an assert(false) in release code in GDC. Try running a backtrace on the application.
Mar 17 2014
prev sibling next sibling parent Johannes Pfau <nospam example.com> writes:
Am Mon, 17 Mar 2014 18:13:36 +0000
schrieb "Demetri" <Supernova2003dh yahoo.com>:

 I wrote a small D program. When compiled with DMD, it works fine, 
 but neither GDC nor LDC2 can catch exceptions thrown from Phobos 
 (proven by GDB). How do I fix this?
 
 Example code:
 
      import std.process;
      void main(){
        try
        {
          spawnProcess(["/dev/null"]);
        }
        catch (Throwable p)
        {
          return;
        }
      }
 

The example works fine here (with exactly the same parameters). Do you have a recent GDC? 32bit/64bit?
Mar 17 2014
prev sibling next sibling parent "Demetri" <Supernova2003dh yahoo.com> writes:
I have GDC 4.8.2, 64 bit

Should I upgrade to 4.9?

On Monday, 17 March 2014 at 18:52:49 UTC, Johannes Pfau wrote:
 Am Mon, 17 Mar 2014 18:13:36 +0000
 schrieb "Demetri" <Supernova2003dh yahoo.com>:

 I wrote a small D program. When compiled with DMD, it works 
 fine, but neither GDC nor LDC2 can catch exceptions thrown 
 from Phobos (proven by GDB). How do I fix this?
 
 Example code:
 
      import std.process;
      void main(){
        try
        {
          spawnProcess(["/dev/null"]);
        }
        catch (Throwable p)
        {
          return;
        }
      }
 

The example works fine here (with exactly the same parameters). Do you have a recent GDC? 32bit/64bit?

Mar 17 2014
prev sibling next sibling parent "Demetri" <Supernova2003dh yahoo.com> writes:
I tried reinstalling GDC, but this test faild with GDC 4.9

On Monday, 17 March 2014 at 20:20:24 UTC, Demetri wrote:
 I have GDC 4.8.2, 64 bit

 Should I upgrade to 4.9?

 On Monday, 17 March 2014 at 18:52:49 UTC, Johannes Pfau wrote:
 Am Mon, 17 Mar 2014 18:13:36 +0000
 schrieb "Demetri" <Supernova2003dh yahoo.com>:

 I wrote a small D program. When compiled with DMD, it works 
 fine, but neither GDC nor LDC2 can catch exceptions thrown 
 from Phobos (proven by GDB). How do I fix this?
 
 Example code:
 
     import std.process;
     void main(){
       try
       {
         spawnProcess(["/dev/null"]);
       }
       catch (Throwable p)
       {
         return;
       }
     }
 

The example works fine here (with exactly the same parameters). Do you have a recent GDC? 32bit/64bit?


Mar 17 2014
prev sibling next sibling parent "Demetri" <Supernova2003dh yahoo.com> writes:
On Monday, 17 March 2014 at 18:52:49 UTC, Johannes Pfau wrote:
 Am Mon, 17 Mar 2014 18:13:36 +0000
 schrieb "Demetri" <Supernova2003dh yahoo.com>:

 I wrote a small D program. When compiled with DMD, it works 
 fine, but neither GDC nor LDC2 can catch exceptions thrown 
 from Phobos (proven by GDB). How do I fix this?
 
 Example code:
 
      import std.process;
      void main(){
        try
        {
          spawnProcess(["/dev/null"]);
        }
        catch (Throwable p)
        {
          return;
        }
      }
 

The example works fine here (with exactly the same parameters). Do you have a recent GDC? 32bit/64bit?

Mar 17 2014
prev sibling next sibling parent Iain Buclaw <ibuclaw gdcproject.org> writes:
On 18 March 2014 01:20, Demetri <Supernova2003dh yahoo.com> wrote:
 On Monday, 17 March 2014 at 18:52:49 UTC, Johannes Pfau wrote:
 Am Mon, 17 Mar 2014 18:13:36 +0000
 schrieb "Demetri" <Supernova2003dh yahoo.com>:

 I wrote a small D program. When compiled with DMD, it works fine, but
 neither GDC nor LDC2 can catch exceptions thrown from Phobos (proven by
 GDB). How do I fix this?

 Example code:

      import std.process;
      void main(){
        try
        {
          spawnProcess(["/dev/null"]);
        }
        catch (Throwable p)
        {
          return;
        }
      }

The example works fine here (with exactly the same parameters). Do you have a recent GDC? 32bit/64bit?

What does gdc -v show on your system? That may help.

On my work system, the last time I built gdc was around 2014/02/21. I cannot reproduce this.
Mar 18 2014
prev sibling parent "Demetri" <Supernova2003dh yahoo.com> writes:
On Tuesday, 18 March 2014 at 09:21:05 UTC, Iain Buclaw wrote:
 On 18 March 2014 01:20, Demetri <Supernova2003dh yahoo.com> 
 wrote:
 On Monday, 17 March 2014 at 18:52:49 UTC, Johannes Pfau wrote:
 Am Mon, 17 Mar 2014 18:13:36 +0000
 schrieb "Demetri" <Supernova2003dh yahoo.com>:

 I wrote a small D program. When compiled with DMD, it works 
 fine, but
 neither GDC nor LDC2 can catch exceptions thrown from Phobos 
 (proven by
 GDB). How do I fix this?

 Example code:

      import std.process;
      void main(){
        try
        {
          spawnProcess(["/dev/null"]);
        }
        catch (Throwable p)
        {
          return;
        }
      }

The example works fine here (with exactly the same parameters). Do you have a recent GDC? 32bit/64bit?

What does gdc -v show on your system? That may help.

On my work system, the last time I built gdc was around 2014/02/21. I cannot reproduce this.

Sorry everyone! The problem was one on my end that was causing all sorts of things to crash. Not being able to catch Phobos exceptions was just the first sign.
Apr 01 2014