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

Leak pthread_{mutex,rwlock}_t if it's dropped while locked. #98194

Merged
merged 2 commits into from
Jun 25, 2022

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Jun 17, 2022

Fixes #85434.

@m-ou-se m-ou-se added A-concurrency Area: Concurrency related issues. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 17, 2022
@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive
Copy link
Collaborator

r? @kennytm

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 17, 2022
@m-ou-se
Copy link
Member Author

m-ou-se commented Jun 18, 2022

r? @Amanieu

@rust-highfive rust-highfive assigned Amanieu and unassigned kennytm Jun 18, 2022
@Amanieu
Copy link
Member

Amanieu commented Jun 19, 2022

Does this issue also apply to pthread_rwlock_t? If so then we should apply the same workaround there.

@m-ou-se
Copy link
Member Author

m-ou-se commented Jun 19, 2022

Attempting to destroy an uninitialized read-write lock results in undefined behavior.

Yes. Updating the PR. :)

@m-ou-se m-ou-se added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 19, 2022
@Amanieu
Copy link
Member

Amanieu commented Jun 19, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jun 19, 2022

📌 Commit b4fe8f3 has been approved by Amanieu

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 19, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 19, 2022
…r=Amanieu

Leak pthreax_mutex_t when it's dropped while locked.

Fixes rust-lang#85434.
@JohnTitor
Copy link
Member

Failed in rollup: #98263 (comment)

error[E0425]: cannot find function `forget` in this scope
--> library/std/src/sys/unix/locks/pthread_rwlock.rs:27:13
|
27|             forget(rwlock);
| ^^^^^^not found in this scope
|
help: consider importing one of these items
|
1| use core::intrinsics::forget;
|
1| use core::mem::forget;
|
1| use crate::intrinsics::forget;
|
1| use crate::mem::forget;
|

Missing import on macOS.
@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 19, 2022
@joshtriplett joshtriplett changed the title Leak pthreax_mutex_t when it's dropped while locked. Leak pthread_mutex_t if it's dropped while locked. Jun 20, 2022
@m-ou-se m-ou-se changed the title Leak pthread_mutex_t if it's dropped while locked. Leak pthread_{mutex,rwlock}_t if it's dropped while locked. Jun 20, 2022
@m-ou-se
Copy link
Member Author

m-ou-se commented Jun 20, 2022

@bors r=Amanieu

@bors
Copy link
Contributor

bors commented Jun 20, 2022

📌 Commit e642c59 has been approved by Amanieu

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 20, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 25, 2022
…r=Amanieu

Leak pthread_{mutex,rwlock}_t if it's dropped while locked.

Fixes rust-lang#85434.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 25, 2022
…askrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#96412 (Windows: Iterative `remove_dir_all`)
 - rust-lang#98126 (Mitigate MMIO stale data vulnerability)
 - rust-lang#98149 (Set relocation_model to Pic on emscripten target)
 - rust-lang#98194 (Leak pthread_{mutex,rwlock}_t if it's dropped while locked.)
 - rust-lang#98298 (Point to type parameter definition when not finding variant, method and associated item)
 - rust-lang#98311 (Reverse folder hierarchy)
 - rust-lang#98401 (Add tracking issues to `--extern` option docs.)
 - rust-lang#98429 (Use correct substs in enum discriminant cast)
 - rust-lang#98431 (Suggest defining variable as mutable on `&mut _` type mismatch in pats)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ecefccd into rust-lang:master Jun 25, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: Concurrency related issues. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Destroying locked Mutex in libstd triggers miri in safe code
7 participants