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

Synchronization primitives not robust against unwinding #59614

Open
jethrogb opened this issue Apr 1, 2019 · 0 comments
Open

Synchronization primitives not robust against unwinding #59614

jethrogb opened this issue Apr 1, 2019 · 0 comments
Labels
C-bug Category: This is a bug. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@jethrogb
Copy link
Contributor

jethrogb commented Apr 1, 2019

Various synchronization primitives in std are not robust against unwinding triggered inside the std implementation. This may result in

  • double panics
  • deadlocks
  • Mutexes being poisoned that shouldn't be

Such unwinding may be triggered in many different ways, for example:

  • pthread_cancel on certain pthread implementations
  • assertion/unwrap failure due to a variety of causes:
    • The kernel may return an unexpected error value from a system call
    • The libc implementation may return an unexpected error from a call
    • An unexpected return value due to the use of Linux seccomp
    • Iago attacks

I've identified at least the following cases. Fixes for some of these have been proposed and rejected in #58042 and #58461.

Primitive Unwind during blocking in Failure occurs in Test case
MPSC oneshot recv/recv_timeout Receiver drop https://github.com/jethrogb/rust/blob/95e8613d4e92f5f4b5487f2e7b4b936ea17d96d2/src/test/run-fail/mpsc-recv-unwind/oneshot.rs
MPSC sync recv/recv_timeout Receiver drop https://github.com/jethrogb/rust/blob/95e8613d4e92f5f4b5487f2e7b4b936ea17d96d2/src/test/run-fail/mpsc-recv-unwind/sync.rs
MPSC shared recv/recv_timeout Receiver drop https://github.com/jethrogb/rust/blob/95e8613d4e92f5f4b5487f2e7b4b936ea17d96d2/src/test/run-fail/mpsc-recv-unwind/shared.rs
MPSC stream recv/recv_timeout Receiver drop https://github.com/jethrogb/rust/blob/95e8613d4e92f5f4b5487f2e7b4b936ea17d96d2/src/test/run-fail/mpsc-recv-unwind/stream.rs
Condvar wait/wait_timeout wait https://github.com/jethrogb/rust/blob/dd20f165ded66619ee040f5d819a4490fad3bd5c/src/test/run-pass/condvar-wait-panic-poison.rs
thread park/park_timeout park/ThreadInfo::with #58461 (comment)
@jethrogb jethrogb changed the title Synchronization primitives in std are not robust against unwinding Synchronization primitives not robust against unwinding Apr 1, 2019
@jonas-schievink jonas-schievink added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Apr 1, 2019
@Enselic Enselic added T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants