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

Manually test that panicking from C will abort the process #290

Merged
merged 1 commit into from
Apr 7, 2021

Conversation

real-or-random
Copy link
Collaborator

@real-or-random real-or-random commented Mar 19, 2021

Panicking from C is not UB in newer rust versions and will reliably
trigger an abort (without unwinding). In older rust versions, it is
technically UB but empirically it seems to "just work" (and what should
it realistically do except crashing, which is what we intent).

Since there's potentially no unwinding, we can't test this behavior
using [should_panic]. This PR will check the exit code instead in our
CI tests.

Fixes #228. This is an alternative to #288.

apoelstra
apoelstra previously approved these changes Mar 23, 2021
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat! ack

contrib/test.sh Outdated Show resolved Hide resolved
@real-or-random
Copy link
Collaborator Author

Okay fixed... I have no idea about WASM builds but AFAIU this currently does not test if the panic works on WASM.

contrib/test.sh Outdated Show resolved Hide resolved
@real-or-random real-or-random force-pushed the 202103_panic_from_c branch 2 times, most recently from 9be4c4e to b27f0fa Compare March 24, 2021 15:30
Panicking from C is not UB in newer rust versions and will reliably
trigger an abort (without unwinding). In older rust versions, it is
technically UB but empirically it seems to "just work" (and what should
it realistically do except crashing, which is what we intent).

Since there's potentially no unwinding, we can't test this behavior
using [should_panic]. This PR will instead check the libtest output
explicitly in our CI tests.

Fixes rust-bitcoin#228.
@real-or-random
Copy link
Collaborator Author

Ok this should be really ready for review now...

Copy link
Member

@elichai elichai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK
Verified that if it panics for another reason it fails
Verified that if it doesn't panic it also fails

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utack

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.

Panics through FFI in error callbacks
3 participants