-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Assert that pthread mutex initialization succeeded #77761
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
r? @cuviper |
I think it's a good idea to enforce this, but the assertion will not be very meaningful to a user. Your change from Maybe they should use |
95618a1
to
01c625e
Compare
Replaced with cvt_nz and unwrap, this should be informative enough coming from Mutex::init, now that we have a track-caller. I intentionally limited this to initialization for now. |
01c625e
to
21c29b1
Compare
LGTM, thanks! @bors r+ rollup |
📌 Commit 21c29b1 has been approved by |
If pthread mutex initialization fails, the failure will go unnoticed unless debug assertions are enabled. Any subsequent use of mutex will also silently fail, since return values from lock & unlock operations are similarly checked only through debug assertions. In some implementations the mutex initialization requires a memory allocation and so it does fail in practice. Check that initialization succeeds to ensure that mutex guarantees mutual exclusion.
Rollup of 10 pull requests Successful merges: - rust-lang#77612 (BTreeMap: test invariants more thoroughly and more readably) - rust-lang#77761 (Assert that pthread mutex initialization succeeded) - rust-lang#77778 ([x.py setup] Allow setting up git hooks from other worktrees) - rust-lang#77838 (const keyword: brief paragraph on 'const fn') - rust-lang#77923 ([net] apply clippy lints) - rust-lang#77931 (Fix false positive for `unused_parens` lint) - rust-lang#77959 (Tweak ui-tests structure) - rust-lang#78105 (change name in .mailmap) - rust-lang#78111 (Trait predicate ambiguities are not always in `Self`) - rust-lang#78121 (Do not ICE on pattern that uses a binding multiple times in generator) Failed merges: r? `@ghost`
If pthread mutex initialization fails, the failure will go unnoticed unless
debug assertions are enabled. Any subsequent use of mutex will also silently
fail, since return values from lock & unlock operations are similarly checked
only through debug assertions.
In some implementations the mutex initialization requires a memory
allocation and so it does fail in practice.
Assert that initialization succeeds to ensure that mutex guarantees
mutual exclusion.
Fixes #34966.