Skip to content

Out of date safety note on #[ffi_function]?  #123

Description

@recatek

This is a complicated topic, so correct me if I'm wrong here, but #[ffi_function] states:

/// # Safety
///
/// ⚠️ You _must_ ensure that methods exported with `#[ffi_function]` will never panic. We highly encourage you
/// to wrap all your code in panic guards. This is a standard Rust FFI concern and has nothing to do with Interoptopus.
/// Failure to follow this advice will probably lead to undefined behavior down the road. The author has been there and does not recommend it.

I believe this is no longer the case now that c_unwind was stabilized and the default behavior for extern "C" was changed in Rust 1.81. See rust-lang/rust#116088

It still may be a good idea to use panic guards for functionality's sake, but I believe it's no longer UB as any extern "C" function that hits a panic will abort rather than let the unwind cross the FFI boundary now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreInteroptopus Core CrateenhancementMake existing things better.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions