File tree Expand file tree Collapse file tree 4 files changed +13
-2
lines changed Expand file tree Collapse file tree 4 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,8 @@ impl Thread {
168168 unsafe {
169169 let ret = libc:: pthread_join ( self . id , ptr:: null_mut ( ) ) ;
170170 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) ) ;
172173 }
173174 }
174175
Original file line number Diff line number Diff line change @@ -273,6 +273,7 @@ pub const FILE_END: DWORD = 2;
273273
274274pub const WAIT_OBJECT_0 : DWORD = 0x00000000 ;
275275pub const WAIT_TIMEOUT : DWORD = 258 ;
276+ pub const WAIT_FAILED : DWORD = 0xFFFFFFFF ;
276277
277278#[ cfg( target_env = "msvc" ) ]
278279pub const MAX_SYM_NAME : usize = 2000 ;
Original file line number Diff line number Diff line change @@ -61,7 +61,11 @@ impl Thread {
6161 }
6262
6363 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+ }
6569 }
6670
6771 pub fn yield_now ( ) {
Original file line number Diff line number Diff line change @@ -1230,6 +1230,11 @@ impl<T> JoinHandle<T> {
12301230 /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
12311231 /// [`panic`]: ../../std/macro.panic.html
12321232 ///
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+ ///
12331238 /// # Examples
12341239 ///
12351240 /// ```
You can’t perform that action at this time.
0 commit comments