-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Abort by default when unwinding through an unsafe
block?
#512
Comments
So this would only abort when the unwinding hits the actual edge of the Uncertain how precise people are with their |
Just another comment I wanted to add: It's important that this wouldn't necessarily mean that all
As written, yes.
Yeah. Provided that people scope their When people scope it too narrowly, I'm not sure if there's anything we can do, at least nearly as easily. The fact that people don't have clear and strong enough guidance about where to put the (But along a similar line of thought, perhaps one way it could be made coarser, if we wanted to, would be to (also?) abort if unwinding hits the outermost scope of any function which contains an |
Note that aborting the process does not ensure memory safety, because processes can share memory. (In general, I think the process-vs-thread distinction is often overemphasized when unwinding is discussed; threads may not share memory, and processes can share memory, so the distinction as far as memory is concerned is about defaults—file descriptors, etc. are a different story, however). |
@glaebhoerl Triage: This issue is largely academic at this point (breaking change). Mind closing? |
FWIW in theory this could still make sense as a kind of per-crate opt-in, or a |
I don't know whether this is a good idea or if it's been considered before, but it at least seems worth considering if it hasn't been.
The idea is simply:
If unwinding (
panic!
) reaches anunsafe
block, the process is aborted unless there is some explicit indication (e.g. a#[unwinding_allowed]
attribute on theunsafe
block, or whatever) that it should keep going.Rationale:
unsafe
blocks are one of the only places in the language where unwinding (exception safety) needs to be explicitly reasoned about. If the programmer neglects to do this, theunsafe
block may actually be unsafe and fail to uphold core memory safety requirements in the presence of unwinding. In this case, aborting isn't anyone's idea of a good time, but it is less bad than corrupted memory and security bugs.It may be more prudent to assume that the programmer hasn't considered the possibility of unwinding until she explicitly indicates otherwise.
Unresolved questions:
Is aborting when unwinding hits the
unsafe
boundary "enough", or by then can it already be "too late"?The text was updated successfully, but these errors were encountered: