-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
"Aborted (core dumped)" with asm! after "error: expected expression, found <eof>
"
#62894
Comments
cc @estebank |
Interesting:
I'm not familiar with /// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
/// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
/// method. Abort the program if the closure panics.
//
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_clobber<T, F>(t: &mut T, f: F) where F: FnOnce(T) -> T {
unsafe {
// Safe because `t` is used in a read-only fashion by `read()` before
// being overwritten by `write()`.
let old_t = ptr::read(t);
let new_t = panic::catch_unwind(panic::AssertUnwindSafe(|| f(old_t)))
.unwrap_or_else(|_| process::abort());
ptr::write(t, new_t);
}
} |
cc @nnethercote |
If I change the body of
then the compiler aborts how you would expect. I caught the panic in gdb (with
So it seems like this is a "legitimate" panic from the parser that the compiler would normally catch gracefully somewhere... except that |
@nnethercote I think there’s no magic trick here. Afaik the only safe way to do this is to mem::replace t with a dummy value, apply f, and swap the result back, but that requires that t has a dummy value. Does the code break if you add T: Default bound? Also, when suggesting that change I was 80% sure that it’s pure pedantry because, clearly, we don’t panic anywhere :) I am fascinated by how conspicuous and shallow such “benign” problems become in rust! |
cc @petrochenkov re:macros/ |
Yes. Unfortunately, lots of the involved types lack a @eddyb wants the commit that introduced
If I'd stuck with the original code that didn't handle panics it would have been a double-free without warning. One of those " |
Or we just accept the current behaviour, because it's a benign abort on a very obscure case, and |
What's the plan post-
Benign to |
Just in case it's useful: here is a variation that causes (what I assume is) the same abort with only the fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! |
I am unable to reproduce this crash on the latest I was curious what fixed it, so I tried bisecting with nightlies. The crash still happens on In any case, as far as I'm concerned, this issue may be closed now. |
Let's close this with a PR containing these repro cases as regression tests. |
Add more regression tests Closes rust-lang#39618 Closes rust-lang#51798 Closes rust-lang#62894 Closes rust-lang#63952 Closes rust-lang#68653 r? @Centril
rustc crashes ungracefully when given the following input (found by fuzz-rustc):
I'm seeing this behavior on stable, beta, and nightly.
The text was updated successfully, but these errors were encountered: