Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

fix Issue 15886 - Add an uncaught exception handler #1533

Closed
wants to merge 1 commit into from

Conversation

CyberShadow
Copy link
Member

https://issues.dlang.org/show_bug.cgi?id=15886

I'm not sure how to do the win32 part. @llucax?

@dlang-bot
Copy link
Contributor

dlang-bot commented Apr 6, 2016

Thanks for your pull request, @CyberShadow!

Bugzilla references

Auto-close Bugzilla Description
15886 Add an uncaught exception handler

@CyberShadow
Copy link
Member Author

For some reason the exception passed to the handler doesn't have a stack trace (when printed with _d_print_throwable), even though _d_createTrace is called on the object. Not sure why. @WalterBright?

@llucax
Copy link

llucax commented Apr 6, 2016

I'm not sure how to do the win32 part. @llucax?

If you are asking me about win32, you are barking at the wrong tree :)

@llucax
Copy link

llucax commented Apr 6, 2016

So in Linux, if no special handler is used, abort() is called but after the stack was unwound?

@CyberShadow
Copy link
Member Author

If you are asking me about win32, you are barking at the wrong tree :)

Ah, git-blame pointed me to 04e29d1, sorry. @donc? :)

So in Linux, if no special handler is used, abort() is called but after the stack was unwound?

Well, if there are no exception frames, there is nowhere to unwind to. Normally there is a top-level frame in _d_run_main, which can be disabled by setting rt_trapExceptions to 0.

@Marenz
Copy link

Marenz commented Apr 7, 2016

So in Linux, if no special handler is used, abort() is called but after the stack was unwound?

As far as I can tell that is not true, output of a small test:

(gdb) break _d_run_main
(gdb) set rt_trapExceptions = 0
(gdb) cont
Continuing.

uncaught exception
dwarfeh(224) fatal error

Program received signal SIGABRT, Aborted.
0x00007ffff740fcc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: Datei oder Verzeichnis nicht gefunden.
(gdb) bt
#0  0x00007ffff740fcc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff74130d8 in __GI_abort () at abort.c:89
#2  0x0000000000423a56 in _d_throwdwarf ()
#3  0x0000000000421bb8 in _d_assert ()
#4  0x0000000000421918 in main.__assert() ()
#5  0x00000000004218ae in D main () at main.d:15
#6  0x00000000004238af in rt.dmain2._d_run_main() ()
#7  0x0000000000423827 in rt.dmain2._d_run_main() ()
#8  0x000000000042386b in rt.dmain2._d_run_main() ()
#9  0x0000000000423827 in rt.dmain2._d_run_main() ()
#10 0x000000000042374a in _d_run_main ()
#11 0x0000000000421968 in main ()

Not sure why I see dwarfeh(224) fatal error though

@CyberShadow
Copy link
Member Author

@Marenz
Copy link

Marenz commented Apr 7, 2016

Ah, makes sense now.

@rainers
Copy link
Member

rainers commented Jul 14, 2017

I'm not sure how to do the win32 part.

SetUnhandledExceptionFilter will probably help, see https://msdn.microsoft.com/en-us/library/ms680634.aspx

@CyberShadow
Copy link
Member Author

SetUnhandledExceptionFilter will probably help, see https://msdn.microsoft.com/en-us/library/ms680634.aspx

Thanks. That's probably going too far for this pull request, so it's probably better to declare that this feature is unsupported on Win32.

@CyberShadow
Copy link
Member Author

A test would be much easier to write once #1538 is in.

@Burgos
Copy link
Member

Burgos commented Jul 15, 2017

See how I got the test for the same functionality, albeit only for dwarfeh: https://github.com/dlang/druntime/pull/1673/files#diff-eb6feae96258d70e7e610bffc21427bc

I was not aware of this PR when writing my own, I guess we shouldn't leave them too long to rot :(.

@dlang-bot dlang-bot added Needs Rebase needs a `git rebase` performed stalled and removed Needs Rebase needs a `git rebase` performed labels Jan 1, 2018
@dlang-bot dlang-bot added Needs Rebase needs a `git rebase` performed Needs Work labels May 27, 2021
@RazvanN7
Copy link
Contributor

RazvanN7 commented Nov 2, 2021

@CyberShadow Care to take another look at this?

@dlang-bot dlang-bot removed the stalled label Nov 2, 2021
@CyberShadow CyberShadow added the Phantom Zone Has value/information for future work, but closed for now label Nov 3, 2021
@CyberShadow
Copy link
Member Author

This would be nice to have for certain situations but does need some more thinking (especially how to approach the platform disparity).

@CyberShadow CyberShadow closed this Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Enhancement New functionality Needs Rebase needs a `git rebase` performed Needs Work Phantom Zone Has value/information for future work, but closed for now
Projects
None yet
7 participants