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

tests: Add "C-unwind" to extern functions that can panic #1354

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

volsa
Copy link
Member

@volsa volsa commented Nov 11, 2024

With Rust 1.81 extern "C" functions are by-default not allowed to unwind and instead follow the panic=abort strategy. As a consequence, the #[should_panic] macro no longer works on extern "C" functions that panic. To mitigate one can change the signature from extern "C" to extern "C-unwind" to change the strategy.

This commit does this for any unit test that uses extern "C" functions in combination with #[should_panic].

See also rust-lang/rust#116088

With Rust 1.81 `extern "C"` functions are by-default not allowed to unwind and instead
follow the `panic=abort` strategy. As a consequence, the `#[should_panic]` macro no longer
works on `extern "C"` functions that panic. To mitigate one can change the signature from
`extern "C"` to `extern "C-unwind"` to change the strategy.

This commit does this for any unit test that uses `extern "C"` functions in combination with `#[should_panic]`.
@volsa volsa requested review from mhasel and ghaith November 11, 2024 12:47
Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 93.75000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 93.54%. Comparing base (be78df6) to head (5720ec4).
Report is 117 commits behind head on master.

Files with missing lines Patch % Lines
libs/stdlib/src/date_time_numeric_functions.rs 91.30% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1354      +/-   ##
==========================================
+ Coverage   91.11%   93.54%   +2.43%     
==========================================
  Files         153      160       +7     
  Lines       44816    48221    +3405     
==========================================
+ Hits        40833    45108    +4275     
+ Misses       3983     3113     -870     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@volsa volsa merged commit 5b9c009 into master Nov 11, 2024
21 checks passed
@volsa volsa deleted the volsa/test-extern-c-unwinding branch November 11, 2024 14:13
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