www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Catch exception from external library

reply Callum Anderson <callumenator gmail.com> writes:
Hi,

Is there any way to catch unhandled exceptions thrown by external libraries? I
am
calling an external C library function, which works fine in release mode,
however
in debug mode it throws a SIGSEV. I would like to debug later parts of the code,
but can;t get past this function when debugging because of the exception.

I have tried putting the function call in try/catch, tried a scope(failure) and
tried collectException() from std.exception. Is it possible to catch these
exceptions?

Thanks alot,
Callum
Aug 10 2011
parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Thursday, August 11, 2011 06:53:57 Callum Anderson wrote:
 Hi,
 
 Is there any way to catch unhandled exceptions thrown by external libraries?
 I am calling an external C library function, which works fine in release
 mode, however in debug mode it throws a SIGSEV. I would like to debug later
 parts of the code, but can;t get past this function when debugging because
 of the exception.
 
 I have tried putting the function call in try/catch, tried a scope(failure)
 and tried collectException() from std.exception. Is it possible to catch
 these exceptions?
SIGSEV is a signal, not an exception. No exception handling code will do anything with it. And pure c code _can't_ throw exceptions of any kind, because C has no exceptions (it _might_ be possible for an exception to come out of C code which called code from another language which _does_ have ecxeptions, but I'm not sure). If you want to handle SIGSEGV, you need a use a signal handler. - Jonathan M Davis
Aug 11 2011
parent reply Callum Anderson <callumenator gmail.com> writes:
Thanks,
SIGSEGV was a brain malfunction on my part sorry. The error was SIG Unhandled
Exception. And I should have said I was calling a C-Api layer on a C++ library.
Does that change anything?
Thanks again,
Callum
Aug 11 2011
next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Thursday, August 11, 2011 07:29:35 Callum Anderson wrote:
 Thanks,
 SIGSEGV was a brain malfunction on my part sorry. The error was SIG
 Unhandled Exception. And I should have said I was calling a C-Api layer on
 a C++ library. Does that change anything?
 Thanks again,
 Callum
I really don't know what happens with C++ exceptions that get thrown when the C++ is wrapped in a C API. So, I can't really help you there. The best that I could do is google for it. - Jonathan M Davis
Aug 11 2011
prev sibling parent reply Russel Winder <russel russel.org.uk> writes:
On Thu, 2011-08-11 at 00:42 -0700, Jonathan M Davis wrote:
 On Thursday, August 11, 2011 07:29:35 Callum Anderson wrote:
 Thanks,
 SIGSEGV was a brain malfunction on my part sorry. The error was SIG
 Unhandled Exception. And I should have said I was calling a C-Api layer=
on
 a C++ library. Does that change anything?
 Thanks again,
 Callum
=20 I really don't know what happens with C++ exceptions that get thrown when=
the=20
 C++ is wrapped in a C API. So, I can't really help you there. The best th=
at I=20
 could do is google for it.
Join ACCU http://accu.org. Get on their general mailing list. Ask there, and you'll either get an answer immediately or an answer will emerge from the ensuing debate. ACCU has a high percentage of very highly knowledgeable and skilled C++ folk, including lots of people on the standards committees. but given it is an organization originally created from a merge of the C User Group, and the European C++ user Group . . . --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Aug 11 2011
parent Callum Anderson <callumenator gmail.com> writes:
Ok thanks for the help, wasn't sure if I was missing something obvious.
Cheers,
Callum
Aug 11 2011