Giter Site home page Giter Site logo

Comments (6)

stevepryde avatar stevepryde commented on August 16, 2024 1

Any reason why this fix hasn't been released yet (and affected versions yanked)? It's a known soundness issue in a popular crate.

from eyre.

stevepryde avatar stevepryde commented on August 16, 2024

Additional details:

  • Mac M1 (macOS 14.2.1)
  • Rust 1.74.1 (also tried on 1.74.0 and 1.73.0, same result)

from eyre.

stevepryde avatar stevepryde commented on August 16, 2024

I get the same segfault also on latest Manjaro Linux (x86-64), using Rust 1.74.1.

from eyre.

abusch avatar abusch commented on August 16, 2024

I've managed to simplify the reproduction case to remove dependencies (thiserror and aws-sdk-ssm are off the hook):

#![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) :

eyre_test(48377,0x1e194d000) malloc: *** error for object 0x1025c23ff: pointer being freed was not allocated
eyre_test(48377,0x1e194d000) malloc: *** set a breakpoint in malloc_error_break to debug

[Process exited 255]

Some things I've noticed:

  • replacing the Other variant with Other(u32) works fine. So does Other (empty variant). But Other(Box<u32>) fails
  • removing .wrap_err() (i.e returning Err(MyError::ClientConstruction.into()) in trigger()) makes it work

from eyre.

ten3roberts avatar ten3roberts commented on August 16, 2024

Thank you for opening the issue.

I will look into it and see what may be causing it

from eyre.

ten3roberts avatar ten3roberts commented on August 16, 2024

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 Other variant is likely because it gives the enum a Drop impl if any fields needs drop. Without it, the box deallocation will take shortcuts when freeing and not drop the contents, but just free

from eyre.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.