Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: relax unwind safety requirements #185

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

Ekleog-NEAR
Copy link
Contributor

As far as I understand unwind safety in rust, this should be safe. First
of all, because unwind "unsafety" in rust is already safe anyway, as
shown by the absence of unsafe keyword.

What it tries to prevent is witnessing a broken invariant in a capture,
after a panic.

Here, we replace RefUnwindSafe with an AssertUnwindSafe that is
exclusively set on a value that will never be reused after the closure
ends.

Hence, to the best of my understanding this still keeps the informal
contract of unwind safety in rust.

In practice, it allows using wasm-smith’s Arbitrary implementation with
with_arbitrary, without having to take bytes as arguments. Without
that, wasm-smith’s ConfiguredModule contains elements that are not
unwind safe, and would be rejected.

I would add that the error message is particularly cryptic, and figuring
out that unwind safety was the source of the issue required me to dig
into bolero’s source code and use the fully-qualified method call
syntax, because without that the full error would not be shown.

It might be possible to hoist the remaining type checks to be earlier in
the call chain (eg. at the with_arbitrary stage), but I haven’t
investigated much deeper yet.

As far as I understand unwind safety in rust, this should be safe. First
of all, because unwind "unsafety" in rust is already safe anyway, as
shown by the absence of `unsafe` keyword.

What it tries to prevent is witnessing a broken invariant in a capture,
after a panic.

Here, we replace `RefUnwindSafe` with an `AssertUnwindSafe` that is
exclusively set on a value that will never be reused after the closure
ends.

Hence, to the best of my understanding this still keeps the informal
contract of unwind safety in rust.

In practice, it allows using wasm-smith’s Arbitrary implementation with
`with_arbitrary`, without having to take bytes as arguments. Without
that, wasm-smith’s ConfiguredModule contains elements that are not
unwind safe, and would be rejected.

I would add that the error message is particularly cryptic, and figuring
out that unwind safety was the source of the issue required me to dig
into bolero’s source code and use the fully-qualified method call
syntax, because without that the full error would not be shown.

It might be possible to hoist the remaining type checks to be earlier in
the call chain (eg. at the with_arbitrary stage), but I haven’t
investigated much deeper yet.
@camshaft camshaft changed the title relax unwind safety requirements fix: relax unwind safety requirements Sep 27, 2023
@camshaft camshaft merged commit 16814dc into camshaft:master Sep 27, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants