Skip to content

UnwindSafe is unrelated to unsafe/rust safety. #6

@rustonaut

Description

@rustonaut

I might be worth to more clear point out that UnwindSafe is misleading, in that it is unrelated to unsafe/rust safety guarantees.

I.e. your type must be rust-safe to reuse after a catch_unwind no matter weather it implements UnwindSafe or not. If it's not it is unsound. Something which is often missed.

UnwindSafe is more like a marker indicating that something plays well with unwinding, instead of it being "rust-safe" wrt. unwinding.

To make things worse it is relatively easy to have code which doesn't play well with unwinding, but does accidentally implement UnwindSafe due *mut T being UnwindSafe if T: RefUnwindSafe... (it is that way due to *mut T often being an owning pointer, but if it's used for a &mut T-like thing you have to explicitly remember to disable it's UnwindSafe implementation).

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