You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
inikulin opened this issue
Jun 11, 2023
· 2 comments
Labels
A-threadArea: `std::thread`C-bugCategory: This is a bug.O-linuxOperating system: LinuxT-libsRelevant to the library team, which will review and decide on the PR/issue.
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/mod.rs:1426:40
stack backtrace:
0: rust_begin_unwind
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
1: core::panicking::panic_fmt
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
2: core::panicking::panic
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
3: core::option::Option<T>::unwrap
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/option.rs:950:21
4: std::thread::JoinInner<T>::join
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/mod.rs:1426:40
5: std::thread::JoinHandle<T>::join
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/mod.rs:1558:9
6: std_thread_bug::main
at ./src/main.rs:4:13
7: core::ops::function::FnOnce::call_once
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
The text was updated successfully, but these errors were encountered:
inikulin
changed the title
std::thread::JoinHandle::join panics with seccomp-killed threadsstd::thread::JoinHandle::join panics with seccomp-killed threads
Jun 11, 2023
What happens here is that .join() will first use pthread_join to wait for the thread which returns a success and then it tries to read the return value that the thread should have written right before finishing:
When a thread is killed, it won't have a chance to write the return value, thus causing the unwrap to fail. Note that killing individual threads without letting them unwind their stack is UB. It doesn't matter if this is through pthread_exit/pthread_kill or seccomp killing the thread. See rust-lang/unsafe-code-guidelines#211 Maybe the .unwrap() should be replaced with an rtabort!() which aborts the process without panicking as the process is in an inconsistent state where continuing may be a security issue?
@bjorn3 thank you for the clarification, killed threads being UB is a useful revelation. As for solution - yeah, aborting sounds like a good measure here.
ChrisDenton
added
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
A-thread
Area: `std::thread`
O-linux
Operating system: Linux
and removed
needs-triage-legacy
Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged.
labels
Nov 6, 2023
A-threadArea: `std::thread`C-bugCategory: This is a bug.O-linuxOperating system: LinuxT-libsRelevant to the library team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen:
join()
call return an error, gracefully reporting the killed threadInstead, this happened:
join()
panics internallyMeta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: