Thread overview
[Issue 15886] Add an uncaught exception handler
Apr 06, 2016
Vladimir Panteleev
Apr 07, 2016
Marenz
Apr 07, 2016
Marenz
Apr 07, 2016
Vladimir Panteleev
Apr 07, 2016
Marenz
Apr 07, 2016
Vladimir Panteleev
Dec 17, 2022
Iain Buclaw
April 06, 2016
https://issues.dlang.org/show_bug.cgi?id=15886

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=4385

--
April 07, 2016
https://issues.dlang.org/show_bug.cgi?id=15886

Marenz <dmdtracker@supradigital.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmdtracker@supradigital.org

--- Comment #1 from Marenz <dmdtracker@supradigital.org> ---
> Currently, rt.dwarfeh calls terminate(__LINE__) which calls abort()

If abort() is called that will — outside of a debugger — create a core dump allowing you to investigate the memory state at the place where the exception was thrown.

I don't see why you would need a hook here?

--
April 07, 2016
https://issues.dlang.org/show_bug.cgi?id=15886

--- Comment #2 from Marenz <dmdtracker@supradigital.org> ---
The bigger problems I found are that you can't set rt_trapExceptions to 0 from inside your program or through environment variables / command line parameters.

So you never actually have a core dump generated other then when started through a debugger (the comments for that variable claim a debugger would set it to 0).

Another problem is that fibers also have an exception trap so the switch doesn't even have an effect there.

That's why I created

https://github.com/D-Programming-Language/druntime/pull/1538

and

https://github.com/D-Programming-Language/druntime/pull/1537

--
April 07, 2016
https://issues.dlang.org/show_bug.cgi?id=15886

--- Comment #3 from Vladimir Panteleev <thecybershadow@gmail.com> ---
(In reply to Marenz from comment #1)
> > Currently, rt.dwarfeh calls terminate(__LINE__) which calls abort()
> 
> If abort() is called that will — outside of a debugger — create a core dump
> allowing you to investigate the memory state at the place where the
> exception was thrown.
> 
> I don't see why you would need a hook here?

A hook is not *NEEDED* but it sure as heck will help. It's very difficult to print the exception object from within abort()'s stack frame, because the exception object may be optimized out and not easily available from the debugger.

(In reply to Marenz from comment #2)
> The bigger problems I found are that you can't set rt_trapExceptions to 0 from inside your program or through environment variables / command line parameters.

Yes, that would be nice (though it does not absolve my need for this
enhancement). It's trivial to set it from within gdb (break main / run / set
rt_trapExceptions=0 / continue).

It could probably also be made settable via environment variables or the command line, like the GC tuning parameters.

> That's why I created
> 
> https://github.com/D-Programming-Language/druntime/pull/1538
> 
> and
> 
> https://github.com/D-Programming-Language/druntime/pull/1537

Nice.

--
April 07, 2016
https://issues.dlang.org/show_bug.cgi?id=15886

--- Comment #4 from Marenz <dmdtracker@supradigital.org> ---
>It's very difficult to print the exception object from within abort()'s stack frame, because the exception object may be optimized out and not easily available from the debugger.

Hm that seems true, I don't seem to be getting any access to it at all because the druntime is not compiled with debugging I guess.

But do you really need that if you have the whole stack available including the place where it was thrown from?

--
April 07, 2016
https://issues.dlang.org/show_bug.cgi?id=15886

--- Comment #5 from Vladimir Panteleev <thecybershadow@gmail.com> ---
Well, yes, exception objects often contain information about the error which otherwise can be difficult to obtain directly from the debugger, such as the error message (obviously), the file name / line number where the exception was created (which may not be in the stack trace), and other exception fields for custom exception types.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=15886

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4

--