Rollup merge of #137480 - fuzzypixelz:fix/124466, r=workingjubilee
Return unexpected termination error instead of panicing in `Thread::join` There is a time window during which the OS can terminate a thread before stdlib can retreive its `Packet`. Currently the `Thread::join` panics with no message in such an event, which makes debugging difficult; fixes #124466.
This commit is contained in:
commit
f19d4b5f97
1 changed files with 10 additions and 1 deletions
|
@ -1739,7 +1739,16 @@ struct JoinInner<'scope, T> {
|
|||
impl<'scope, T> JoinInner<'scope, T> {
|
||||
fn join(mut self) -> Result<T> {
|
||||
self.native.join();
|
||||
Arc::get_mut(&mut self.packet).unwrap().result.get_mut().take().unwrap()
|
||||
Arc::get_mut(&mut self.packet)
|
||||
// FIXME(fuzzypixelz): returning an error instead of panicking here
|
||||
// would require updating the documentation of
|
||||
// `std::thread::Result`; currently we can return `Err` if and only
|
||||
// if the thread had panicked.
|
||||
.expect("threads should not terminate unexpectedly")
|
||||
.result
|
||||
.get_mut()
|
||||
.take()
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue