Skip to content

Unwinding into FFI is undefined behavior #56

Open
@janderholm

Description

@janderholm

Some of the examples are using the assert! macro. This will panic and thus unwind. Unwinding across FFI boundaries however is undefined behavior and needs to be catched.

This can be solved either by:

  1. Build with panic = "abort" in cargo.toml
  2. Use std::panic::catch_unwind to catch the unwinding before it hits FFI code
  3. Same as 2. but made easier by using the macro callback_guard! from the glib crate

I prefer number 1 (better performance) as long as the library created does not actively use unwinding, for example by restarting paniced threads. Since unwinding is a very important topic when it comes to FFI I think there should be a chapter with pros and cons in the book.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions