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:
@@ -1739,7 +1739,11 @@ struct JoinInner<'scope, T> {
|
|||||||
impl<'scope, T> JoinInner<'scope, T> {
|
impl<'scope, T> JoinInner<'scope, T> {
|
||||||
fn join(mut self) -> Result<T> {
|
fn join(mut self) -> Result<T> {
|
||||||
self.native.join();
|
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)"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user