Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for `recover` stabilization #27719
Comments
aturon
added
T-libs
B-unstable
labels
Aug 12, 2015
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Aug 31, 2015
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Aug 31, 2015
alexcrichton
referenced this issue
Aug 31, 2015
Closed
std: Rename thread::catch_panic to panic::recover #28128
This comment has been minimized.
This comment has been minimized.
|
I’m playing with making Python bindings for a Rust library, and I got some segfaults when a Rust panic tried to unwind into the Python interpreter’s call stack. I understand that using
@wycats, how do you deal with panics in Rust-inside-Ruby? |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin Looking at the guts of unwinding, I agree, though, the type could be a lot more informative here. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I ended up finding this code: https://github.com/rust-lang/rust/blob/d2047bc97d/src/libstd/panicking.rs#L33-L39 , but it’s not very discoverable. And though
So I wanted to propose changing from this (in type Result<T> = Result<T, Box<Any + Send + 'static>>;to this: type Result<T> = Result<T, PanicValue>;
struct PanicValue(Box<Any + Send + 'static>);
impl PanicValue {
fn as_str(&self) -> Option<&str> {
match self.0.downcast_ref::<&'static str>() {
Some(s) => Some(*s),
None => match self.0.downcast_ref::<String>() {
Some(s) => Some(&s[..]),
None => None,
}
}
}
}… but |
This comment has been minimized.
This comment has been minimized.
|
Would this |
This comment has been minimized.
This comment has been minimized.
|
Why not have In fact, why not cover all the primitives (except obviously |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Nov 19, 2015
alexcrichton
referenced this issue
Nov 19, 2015
Merged
std: Rename thread::catch_panic to panic::recover #29937
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Nov 19, 2015
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Nov 19, 2015
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Nov 20, 2015
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Nov 20, 2015
abonander
referenced this issue
Dec 1, 2015
Open
Make the `impl Debug for Any (+ Send)` (and `Box` forms) more useful #1389
This comment has been minimized.
This comment has been minimized.
alexchandel
commented
Dec 2, 2015
|
Why are we making it easier to use and abuse panics, instead of removing inappropriate ones from the standard library? |
This comment has been minimized.
This comment has been minimized.
|
@alexchandel Even if you don’t choose to use panics, it’s very hard to be 100% sure that a non-trivial program will not panic ever. (Similar to being 100% sure that it doesn’t have any bug.) And since unwinding through an FFI boundary can be undefined behavior, something like |
This comment has been minimized.
This comment has been minimized.
There is a whole "Motivations" section of the related RFC which describes this https://github.com/alexcrichton/rfcs/blob/stabilize-catch-panic/text/0000-stabilize-catch-panic.md#motivation |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Dec 5, 2015
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Dec 5, 2015
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Dec 5, 2015
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Dec 8, 2015
bors
added a commit
that referenced
this issue
Dec 8, 2015
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Dec 8, 2015
bors
added a commit
that referenced
this issue
Dec 8, 2015
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Dec 9, 2015
bors
added a commit
that referenced
this issue
Dec 9, 2015
michaelwoerister
added a commit
to michaelwoerister/rust
that referenced
this issue
Dec 10, 2015
This comment has been minimized.
This comment has been minimized.
|
My concern with the current bounds is still less with anything about the API itself than with the fact that this changes the rather strange nature of rustc's OIBIT handling (#27554) from something that was probably rarely encountered in practice to something exposed in a stable API in the standard library. This is going to make changing the OIBIT semantics without breaking the world really hard, and I don't think enough thought has been put into the current form to make locking the language into it desirable. |
This comment has been minimized.
This comment has been minimized.
|
Naming I would refrain from using "unwind": It's not currently exposed in the stdlib, and also, it could mean "to relax", which is the opposite of panicking, really :-) And if "catch" is undesirable (I don't remember exactly why) then maybe PanicInfo The panic handlers added the PanicInfo struct, and recover/propagate has been some kind of parallel process. It would be nice if this API could be a little more consistent, so that recover would actually return a panicinfo somehow, and propagate allowed to take one as a parameter. I'm not exactly sure if this means redesigning PanicInfo, so I'm just going to leave that as a thought for now. Landing pads for extern fn I was wondering if we need an abort-on-panic landing pad on extern fns. Even with this interface stablized, the code is going to end up like:
...it's going to be hard to guarantee to 100% that the "convert to some sort of error" part is never going to panic. Since we don't want UB, maybe we need to insert an abort-on-panic landing pad as part of all extern fn? |
This comment has been minimized.
This comment has been minimized.
|
On Sat, Mar 12, 2016 at 12:13:56PM -0800, wthrowe wrote:
I think the most prominent use of auto traits (aka OIBIT) is
I am not sure what changes you are describing (there are none in the |
This comment has been minimized.
This comment has been minimized.
|
I'm happy to see the progress here, and just as happy that we've managed to smooth over the ergonomics without throwing out the bounds entirely. Unsurprisingly, I'm +1 to a more descriptive name than "recover". This topic comes up so much in the wild that we're going to be perpetually fielding responses to questions like "why does Rust now have exceptions?" and having self-explanatory naming would make that so much less tedious. To reiterate:
I like @nikomatsakis 's |
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix semi-jokingly proposes |
This comment has been minimized.
This comment has been minimized.
|
what about "intercept"? |
twittner
added a commit
to wireapp/cryptobox-c
that referenced
this issue
Mar 29, 2016
This comment has been minimized.
This comment has been minimized.
|
Looks like the discussion is still open for a name so I'll throw out a few ideas. This thread's a little long and these are somewhat generic so it's a little too tedious this late at night to Ctrl-F to see if any of them have already been mentioned, so bear with me.
I kind of agree with the abort landing pads in |
This comment has been minimized.
This comment has been minimized.
|
So far the front-runner in terms of naming to me is For the propagation function, I'd expect something similar like |
This comment has been minimized.
This comment has been minimized.
|
I like It is worth noting, though, that |
This comment has been minimized.
This comment has been minimized.
|
When considering names, the module path is relevant because functions are typically called via it. Things like Returning #27719 (comment), particularly its suggestion of introducing a submodule to |
This comment has been minimized.
This comment has been minimized.
|
Like @sfackler, I prefer |
This comment has been minimized.
This comment has been minimized.
|
I think I'm happy as long as |
This comment has been minimized.
This comment has been minimized.
|
I thought the To me Update: |
This comment has been minimized.
This comment has been minimized.
e-oz
commented
Apr 6, 2016
|
My vote against "barrier", sounds too non-related to execution flow. On Wed, 6 Apr 2016 at 22:32, Felix S Klock II notifications@github.com
|
This comment has been minimized.
This comment has been minimized.
|
In system programming, |
This comment has been minimized.
This comment has been minimized.
|
The libs team discussed this during triage yesterday and the decision was to stabilize with the following names:
Thanks again for all the discussion everyone! |
This comment has been minimized.
This comment has been minimized.
|
yay :) |
aturon commentedAug 12, 2015
The
recoverfunction is able, on a single thread, to recover from a panic. There are numerous controversies around this API, including the bounds it applies to its closure, its safety, and its location withinstd. An open RFC seeks to settle these issues and open the door to stabilization.cc @alexcrichton