Thread overview
Can't catch Phobos exceptions
Mar 17, 2014
Demetri
Mar 17, 2014
Iain Buclaw
Mar 17, 2014
Johannes Pfau
Mar 17, 2014
Demetri
Mar 17, 2014
Demetri
Mar 18, 2014
Demetri
Mar 18, 2014
Iain Buclaw
Apr 01, 2014
Demetri
March 17, 2014
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.
March 17, 2014
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.
March 17, 2014
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?
March 17, 2014
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?

March 17, 2014
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?

March 18, 2014
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.
March 18, 2014
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.
April 01, 2014
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.