-
Notifications
You must be signed in to change notification settings - Fork 66
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
Segfault in Report::downcast()
introduced in 0.6.9
#141
Comments
Additional details:
|
I get the same segfault also on latest Manjaro Linux (x86-64), using Rust 1.74.1. |
I've managed to simplify the reproduction case to remove dependencies ( #![allow(dead_code)]
use std::{error::Error, fmt::Display};
use eyre::Context;
fn main() {
let err = trigger().unwrap_err();
let _ = err.downcast::<MyError>();
println!("it worked!");
}
#[derive(Debug)]
enum MyError {
ClientConstruction,
Other(String),
}
impl Display for MyError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "MyError error")
}
}
impl Error for MyError {}
fn trigger() -> eyre::Result<()> {
Err(MyError::ClientConstruction).wrap_err("failed")
} The failure I get is slightly different (on a Mac M1 Sonoma 14.2) :
Some things I've noticed:
|
Thank you for opening the issue. I will look into it and see what may be causing it |
I believe it is that the inner error is incorrectly freed even though it was downcasted, we still need to free the wrapped error. The content of the |
The context chain downcast called converted to the wrong inner type which caused the wrong drop impl to be called. The tests did not catch this because they had compatible drop implementations due to matching type layout. Solved by swizzling the fields of the chain test types to force incompatible layouts
The context chain downcast called converted to the wrong inner type which caused the wrong drop impl to be called. The tests did not catch this because they had compatible drop implementations due to matching type layout. Solved by swizzling the fields of the chain test types to force incompatible layouts Resolves: #141
Any reason why this fix hasn't been released yet (and affected versions yanked)? It's a known soundness issue in a popular crate. |
I recently had a test segfault after updating to the latest eyre (0.6.11). The same test passes on 0.6.8 but segfaults on 0.6.9 or later.
Here is a minimal reproduction:
Cargo.toml deps
I included the test because
cargo test
gives slightly more info.Something about the second error variant is related, even though that variant isn't constructed.
I used
aws_sdk_ssm::Error
in the error variant because that's how I hit the issue.The issue seems to be in src/error.rs, in
context_drop_rest()
, which was changed in 0.6.9. Any reason why this code differs fromanyhow
?The text was updated successfully, but these errors were encountered: