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

a panic should never unwind the stack past the FFI #553

Closed
laser opened this issue Mar 13, 2019 · 2 comments
Closed

a panic should never unwind the stack past the FFI #553

laser opened this issue Mar 13, 2019 · 2 comments
Assignees
Labels

Comments

@laser
Copy link
Contributor

laser commented Mar 13, 2019

Description

go-filecoin depends on rust-fil-proofs via CGO. A panic in rust-fil-proofs should not propagate to go-filecoin where it cannot be handled.

Acceptance criteria

Trap all panics at the FFI boundary. Transmute panic to an error message, and send that error message back to FFI consumer.

Where to start

This portion of the Rust docs outline an approach for catching panics before propagating back to FFI consumers. This blog post gives some examples of how we might use the UnwindSafe trait.

@laser laser self-assigned this May 6, 2019
@laser laser added the good first issue Good for newcomers label May 6, 2019
vmx added a commit that referenced this issue May 31, 2019
This code currently doesn't even compile. But I upload it though, in case
someone else would like to push that over the finish line.

Closes #553.
@vmx vmx mentioned this issue May 31, 2019
@laser laser removed their assignment Jun 4, 2019
vmx added a commit to filecoin-project/rust-fil-sector-builder that referenced this issue Jun 23, 2019
This is a new WIP about catching panics. If we can agree that this is the
way to go, it would make sense to put this macro into rust-fil-ffi-toolkit.

This patch is best viewed with `git diff --ignore-all-space`.

Closes filecoin-project/rust-fil-proofs#553.
vmx added a commit to filecoin-project/rust-fil-sector-builder that referenced this issue Jun 23, 2019
This is a new WIP about catching panics. If we can agree that this is the
way to go, it would make sense to put this macro into rust-fil-ffi-toolkit.

This patch is best viewed with `git diff --ignore-all-space`.

Closes filecoin-project/rust-fil-proofs#553.
@laser laser assigned laser and vmx and unassigned laser Jul 19, 2019
@laser
Copy link
Contributor Author

laser commented Jul 23, 2019

Also see @vmx PR to cbdingen: mozilla/cbindgen#347 (comment)

@laser laser self-assigned this Jul 23, 2019
@laser laser removed their assignment Sep 17, 2019
vmx added a commit to filecoin-project/rust-fil-ffi-toolkit that referenced this issue Oct 17, 2019
When panics happen on the Rust side of the FFI, normally it just aborts
and the caller has no chance to catch the error.

When a a FFI function is wrapped in a `catch_panic_response()` closure,
then whenever a panic (where unwinding is possible) occurs it will respond
to the caller with the `FCPResponseStatus::FCPUnclassifiedError` error code
and the error message prefixed with "Rust panic: ". Now the caller can
react accordingly.

This is part of filecoin-project/rust-fil-proofs#553
vmx added a commit to filecoin-project/rust-fil-proofs-ffi that referenced this issue Oct 17, 2019
When panics happen, don't just abort, but catch them and send an error
response back with status code `FCPResponseStatus::FCPUnclassifiedError`
and an error message prefixed with "Rust panic: ".

This is part of filecoin-project/rust-fil-proofs#553
vmx added a commit to filecoin-project/rust-fil-proofs-ffi that referenced this issue Oct 23, 2019
When panics happen, don't just abort, but catch them and send an error
response back with status code `FCPResponseStatus::FCPUnclassifiedError`
and an error message prefixed with "Rust panic: ".

This is part of filecoin-project/rust-fil-proofs#553
laser pushed a commit to filecoin-project/rust-fil-proofs-ffi that referenced this issue Oct 23, 2019
* feat: use enum for FFI response status

Use the central `FCPResponseStatus` enum from ffi-toolkit for the
FFI responses.

Closes #8.

* fix: catch panics

When panics happen, don't just abort, but catch them and send an error
response back with status code `FCPResponseStatus::FCPUnclassifiedError`
and an error message prefixed with "Rust panic: ".

This is part of filecoin-project/rust-fil-proofs#553
vmx added a commit to filecoin-project/rust-fil-sector-builder that referenced this issue Oct 23, 2019
When panics happen, don't just abort, but catch them and send an error
response back with status code `FCPResponseStatus::FCPUnclassifiedError`
and an error message prefixed with "Rust panic: ".

This is part of filecoin-project/rust-fil-proofs#553

TODO: update Cargo.lock
vmx added a commit to filecoin-project/rust-fil-sector-builder that referenced this issue Oct 23, 2019
When panics happen, don't just abort, but catch them and send an error
response back with status code `FCPResponseStatus::FCPUnclassifiedError`
and an error message prefixed with "Rust panic: ".

This is part of filecoin-project/rust-fil-proofs#553
vmx added a commit to filecoin-project/rust-fil-sector-builder that referenced this issue Oct 28, 2019
When panics happen, don't just abort, but catch them and send an error
response back with status code `FCPResponseStatus::FCPUnclassifiedError`
and an error message prefixed with "Rust panic: ".

This is part of filecoin-project/rust-fil-proofs#553
vmx added a commit to filecoin-project/rust-fil-sector-builder that referenced this issue Oct 28, 2019
When panics happen, don't just abort, but catch them and send an error
response back with status code `FCPResponseStatus::FCPUnclassifiedError`
and an error message prefixed with "Rust panic: ".

This is part of filecoin-project/rust-fil-proofs#553
vmx added a commit to filecoin-project/rust-fil-sector-builder that referenced this issue Oct 30, 2019
When panics happen, don't just abort, but catch them and send an error
response back with status code `FCPResponseStatus::FCPUnclassifiedError`
and an error message prefixed with "Rust panic: ".

This is part of filecoin-project/rust-fil-proofs#553
laser pushed a commit to filecoin-project/rust-fil-sector-builder that referenced this issue Oct 30, 2019
When panics happen, don't just abort, but catch them and send an error
response back with status code `FCPResponseStatus::FCPUnclassifiedError`
and an error message prefixed with "Rust panic: ".

This is part of filecoin-project/rust-fil-proofs#553
@vmx
Copy link
Contributor

vmx commented Nov 12, 2019

I close this issue as fil-proofs-ffi and sector-builder-ffi now have their panics caught.

@vmx vmx closed this as completed Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants