File tree 4 files changed +13
-2
lines changed
4 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,8 @@ impl Thread {
168
168
unsafe {
169
169
let ret = libc:: pthread_join ( self . id , ptr:: null_mut ( ) ) ;
170
170
mem:: forget ( self ) ;
171
- debug_assert_eq ! ( ret, 0 ) ;
171
+ assert ! ( ret == 0 ,
172
+ "failed to join thread: {}" , io:: Error :: from_raw_os_error( ret) ) ;
172
173
}
173
174
}
174
175
Original file line number Diff line number Diff line change @@ -273,6 +273,7 @@ pub const FILE_END: DWORD = 2;
273
273
274
274
pub const WAIT_OBJECT_0 : DWORD = 0x00000000 ;
275
275
pub const WAIT_TIMEOUT : DWORD = 258 ;
276
+ pub const WAIT_FAILED : DWORD = 0xFFFFFFFF ;
276
277
277
278
#[ cfg( target_env = "msvc" ) ]
278
279
pub const MAX_SYM_NAME : usize = 2000 ;
Original file line number Diff line number Diff line change @@ -61,7 +61,11 @@ impl Thread {
61
61
}
62
62
63
63
pub fn join ( self ) {
64
- unsafe { c:: WaitForSingleObject ( self . handle . raw ( ) , c:: INFINITE ) ; }
64
+ let rc = unsafe { c:: WaitForSingleObject ( self . handle . raw ( ) , c:: INFINITE ) } ;
65
+ if rc == c:: WAIT_FAILED {
66
+ panic ! ( "failed to join on thread: {}" ,
67
+ io:: Error :: last_os_error( ) ) ;
68
+ }
65
69
}
66
70
67
71
pub fn yield_now ( ) {
Original file line number Diff line number Diff line change @@ -1230,6 +1230,11 @@ impl<T> JoinHandle<T> {
1230
1230
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
1231
1231
/// [`panic`]: ../../std/macro.panic.html
1232
1232
///
1233
+ /// # Panics
1234
+ ///
1235
+ /// This function may panic on some platforms if a thread attempts to join
1236
+ /// itself or otherwise may create a deadlock with joining threads.
1237
+ ///
1233
1238
/// # Examples
1234
1239
///
1235
1240
/// ```
You can’t perform that action at this time.
0 commit comments