#unwind #abort #panic

macro unwind_aborts

Prevent your panics from unwinding past FFI boundaries with this one simple trick!

2 releases

0.1.1 Mar 28, 2020
0.1.0 Mar 28, 2020

#234 in FFI

28 downloads per month

MIT license

5KB

unwind_aborts

Prevent your panics from unwinding past FFI boundaries with this one simple trick!

Intended to be used in place of #[unwind(aborts)] until it is stabilized.

Usage

Add this to your [dependencies] in Cargo.toml:

unwind_aborts = "0.1.0"

Annotate your functions with #[unwind_aborts] to catch stack unwinding and abort the process instead:

use unwind_aborts::unwind_aborts;

#[unwind_aborts]
pub extern fn foo() {
    panic!("this is safe");
}

The example above is equivalent to:

pub extern fn foo() {
    let result = std::panic::catch_unwind(|| {
        panic!("this is safe");
    });
    match result {
        Ok(x) => x,
        Err(_) => std::process::abort(),
    }
}

lib.rs:

Prevent your panics from unwinding past FFI boundaries with this one simple trick!

Intended to be used in place of #[unwind(aborts)] until it is stabilized.

Usage

Add this to your [dependencies] in Cargo.toml:

unwind_aborts = "0.1.0"

Annotate your functions with #[unwind_aborts] to catch stack unwinding and abort the process instead:

use unwind_aborts::unwind_aborts;

#[unwind_aborts]
pub extern fn foo() {
    panic!("this is safe");
}

The example above is equivalent to:

pub extern fn foo() {
    let result = std::panic::catch_unwind(|| {
        panic!("this is safe");
    });
    match result {
        Ok(x) => x,
        Err(_) => std::process::abort(),
    }
}

Dependencies

~1.5MB
~33K SLoC