-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Display in test fails with SIGILL (illegal instruction) #69558
Comments
This seems to be due to the |
I can reproduce. This seems to happen if LOCAL_STDERR is initialized (e.g., with set_panic) which leads us to this code. Note that the RefCell there is borrowed so that we can write to it, but then when we go to panic we try to temporarily take the value out. This borrows the RefCell mutably, again, leading to a panic. Since this happens within an existing panic, we abort the process. Smaller example: #![feature(set_stdio, print_internals)]
use std::fmt::{Display, Formatter};
use std::fmt;
use std::io::set_panic;
pub struct A;
impl Display for A {
fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result {
panic!();
}
}
fn main() {
set_panic(Some(Box::new(Vec::new())));
std::io::_eprint(format_args!("{}", A));
} |
This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes rust-lang#69558
…Mark-Simulacrum std: Don't abort process when printing panics in tests This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes rust-lang#69558
This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes rust-lang#69558
…Mark-Simulacrum std: Don't abort process when printing panics in tests This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes rust-lang#69558
…Mark-Simulacrum std: Don't abort process when printing panics in tests This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes rust-lang#69558
…Mark-Simulacrum std: Don't abort process when printing panics in tests This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes rust-lang#69558
I tried this code (using
cargo test
):I expected to see this happen:
The thread should've panicked with 'Index out of bounds: the len is 0 but the index is 0'
Instead, this happened:
Thread crashes with SIGILL (illegal instruction)
Meta
This bug works in stable, beta and nightly.
It also does the same in rust playground.
Here is my cpu info (I figured that it might be useful given the nature of the bug).
The bug doesn't appear if run from main, nor if run directly (without passing from the Display impl).
rustc --version --verbose
:Backtrace
running 1 test
thread panicked while processing panic. aborting.
error: test failed, to rerun pass '--lib'
Caused by:
process didn't exit successfully:
/path/to/proj/target/debug/deps/proj-296b7cb53c6210d6
(signal: 4, SIGILL: illegal instruction)The text was updated successfully, but these errors were encountered: