Return error on unexpected termination 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:
parent
bb2cc59a21
commit
db1f0d0458
1 changed files with 5 additions and 1 deletions
|
@ -1739,7 +1739,11 @@ 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()
|
||||
if let Some(packet) = Arc::get_mut(&mut self.packet) {
|
||||
packet.result.get_mut().take().unwrap()
|
||||
} else {
|
||||
Err(Box::new("thread terminated unexpectedly (e.g. due to OS intervention)"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue