-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Why does panicking in a Drop impl cause SIGILL? #81895
Comments
It calls |
Oh... I think I might've seen a thread about that somewhere. Can we change it somehow so LLVM doesn't turn it into |
There's a message ("thread panicked while panicking. aborting.") )in the output that points out the cause and what will be done. With that in mind does it really matter that it aborts with a
|
I guess when I see |
So SIGILL means "to execute ud2 or some other illegal instruction", and has the same effect in practice as SIGABRT. |
Also consider that |
Why do you think so? Perhaps due to their bad reputation? :) Note that it is not a |
I guess when I hear "illegal" it makes me think there's a memory issue. It's not very rational :) |
I ended up finding this thread because I was confused by seeing SIGILL because I also assumed that if I was getting it that it meant I had a memory management problem. The whole idea with using Rust instead of C++ is not seeing SIGBUS, SIGSEGV, SIGILL etc anymore so I assumed I had made a mistake ;) But a panic during a panic is not technically unsafe (though it is guaranteed to end your program). I'm not sure if there is anything that could be done to make this clearer to the user. At least it seems it should be documented somewhere that comes up earlier in google results than this github issue. Maybe in the nomicon. |
We could add additional blurb to the
I guess? Like "thread panicked while panicking. forcing termination via CPU trap". If people search for what CPU trap means they get wikipedia as first hit. |
Or:
Do you get a SIGILL on all architectures, or just x86-64? |
You are not guaranteed to get SIGILL everywhere, no. Some targets may even end up calling an |
If it doesn't always use a trap, then it's probably more confusing to add "aborting via CPU trap". Maybe we could just add documentation to the reference about this? |
It does almost always use a trap of some sort, though. It will do so for the 99.manynines% of the market share. Targets supported by Rust that do not use a CPU trap to abort this way are pretty much just msp430 right now AFAIK. I'm not sure the reference would be the right place to describe what is effectively an implementation detail of the standard library. |
There is another behavior: for WebAssembly, the trap will end up as a I think the root of the confusion mostly comes from stating Thus I think changing that word to "trapping" would alleviate the problem, regardless of whether we add extra information to explain what happened [*]. It would be more correct, more specific (easier to search for) and hints the user something is going on, different from the usual "abort" they may be accustomed to from Related: I'd argue [*] If we wanted to be even more user-friendly, we could add a custom message per arch that explains what the trap actually does for that target, e.g.:
|
Hmm, doesn't SystemZ have multithreading? If so, this seems invalid. |
Ah, it does create a loop to itself plus two bytes, so I guess it is done as a way to jump into an illegal instruction (or perhaps a misaligned address). Edited, thanks! |
From a quick test under user QEMU, that jump in SystemZ ends up as a segmentation fault, rather than an illegal instruction. AArch64, instead, gives So if those behaviors are faithful to what happens natively, it seems worth to give a custom message even when considering only Linux targets, e.g.:
|
We could just be more vague and say:
|
I think this is a duplicate of #40230, or the other way around. |
One thing that might be worth noting is that this causes problems with tests that An easy way to reproduce this is to have something that needs to be modified otherwise it panics in The case that I'm running into is that I have a tree structure that has nodes that will panic unless they're traversed. That way I don't have to explicitly assert that everything that I need accessed was during the test, and the test will simply fail if the algorithm doesn't traverse in the correct way. But this only works if such test runs to completion and the nodes are |
I'm going to close this since the behavior was documented in #85377 and we're not planning to change it. |
Why does this code trigger a SIGILL when run? I think what's happening is the
first element is dropped, which causes a panic, and then the second element is
dropped, which causes another panic. But why does that cause SIGILL?
My understanding from #53814 is that this is expected behavior (not a bug), but
I'm curious why it happens. I would think if anything it would trigger a
SIGABRT.
code
(playground)
stderr
The text was updated successfully, but these errors were encountered: