Skip to content

Unsound usage of no_mangle #13

@Nemo157

Description

@Nemo157
#[no_mangle]
pub fn async_log_capture_caller() {
    panic!("wat");
}

fn main() {
    std::env::set_var("RUST_BACKTRACE", "1");
    async_log::Logger::wrap(femme::pretty::Logger::new(), || 12)
        .start(log::LevelFilter::Trace)
        .unwrap();
    log::info!("Hello, world!");
    async_log_capture_caller();
}
> cargo add femme@1 async-log@2 [email protected]
> cargo run
     Running `target/debug/foo`
●  Hello, world!, filename=/private/var/folders/0p/5yvmrvhj5w3_vy1y8x7dvk7m0000gn/T/tmp.AWJu4vYd/foo/src/main.rs, line=11, fn_name=foo::main::h3c9bc8b278fd41da
   src/main.rs:11
   › thread_id: 1
   › task_id: 12

[1]    76248 segmentation fault  cargo run

You have no guarantees that there is no other crate or non-Rust linked code using the global symbol async_log_capture_caller, so this crate should document that it reserves that name for its internal usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions