Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior on uncaught exception is different between -C panic=abort and -C panic=unwind #33812

Closed
tomaka opened this issue May 23, 2016 · 7 comments

Comments

@tomaka
Copy link
Contributor

tomaka commented May 23, 2016

When a program compiled with -C panic=abort panicks, the stack trace is printed and an illegal instruction is triggered (with the ud2 opcode).
When a program compiled with -C panic=unwind doesn't catch a panic in the main thread, the stack trace is printed and the program aborts.

I don't have any strong opinion in favor of triggering an illegal instruction vs aborting, but I think the behavior should be the same between panic=abort and panic=unwind.

@huonw
Copy link
Member

huonw commented May 23, 2016

and the program aborts

To be clear, I think this should read "and the program calls exit(101)", which is different to both libc::abort() and std::intrinsics::abort() (the latter is actually how the ud2s are created).

@alexcrichton
Copy link
Member

I'm not sure I understand what this issue is about, unfortunately. The information about stack traces above seems irrelevant, and otherwise it seems obvious that the behavior of a panic changes when you change the panic runtime? Panicking with panic=unwind without a catch is undefined behavior, so it's just an implementation detail what it does.

@retep998
Copy link
Member

retep998 commented May 23, 2016

I'd really prefer if we called DebugBreak whenever there was an uncaught panic on Windows (or at the very least if IsDebuggerPresent()) just to make debugging a bit easier, because otherwise with panic=unwind it is silently caught and the program exits cleanly (!) with an exit code of 101.

@briansmith
Copy link
Contributor

I'd really prefer if we called DebugBreak

Call __debugbreak() instead. DebugBreak can screw up call stacks (see old fixed bugs in the Firefox bug tracker).

@retep998
Copy link
Member

@briangreenery Of course __debugbreak() is an intrinsic so we'd have to either hope LLVM has that intrinsic, or use inline assembly.

@alexcrichton
Copy link
Member

In any case as I mentioned before the behavior of -C panic=unwind is undefined if there's nothing to catch a panic, and with a lack of response I'm going to close this issue as well.

If there's something Windows-specific that should happen here, it would be best to open a new issue.

@retep998
Copy link
Member

I opened a separate issue for that #34502

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants