2

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.

Demi
  • 3,535
  • 5
  • 29
  • 45
  • Could you include a little more informations, like your GDC / LDC2 Some example code would help aswell. – Geod24 Mar 17 '14 at 17:48
  • Did you install the phobos and druntime libraries with ldc and gdc too? dmd uses a different exception scheme, so if the library throws a dmd style exception and the app is trying to catch a gnu style exception, that might explain the problem. – Adam D. Ruppe Mar 17 '14 at 19:16
  • I built ldc and gdc from source, so they provide their own libraries – Demi Mar 17 '14 at 20:18
  • hmm, I can't reproduce this, though I'm using the gdc binary download. I'm still reasonably certain it has to do with a library mismatch of some sort, but I can't be sure and don't have a fix :( – Adam D. Ruppe Mar 19 '14 at 19:44
  • Where is the binary download? I would love to know! – Demi Mar 19 '14 at 20:38

1 Answers1

0

It's probably a library mismatch as Adam D. Ruppe noted. Make sure that you're using the correct library via a custom dmd.conf. Don't forget to add a -L switch to your correct libphobos.

The binary download is here.

Panke
  • 156
  • 9