Skip to content

Commit a6581d2

Browse files
committed
Haiku: Revert "std: Handle OS errors when joining threads"
This reverts commit dc7c7ba. There is an issue with threading in cargo, where thread::join fails after completing a build. This prevents building Rust on Haiku (as the build system kills itself after failure). The problem is documented at rust-on-haiku.com issue #10
1 parent 88f19c6 commit a6581d2

File tree

4 files changed

+2
-11
lines changed

4 files changed

+2
-11
lines changed

library/std/src/sys/unix/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl Thread {
176176
unsafe {
177177
let ret = libc::pthread_join(self.id, ptr::null_mut());
178178
mem::forget(self);
179-
assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret));
179+
debug_assert_eq!(ret, 0);
180180
}
181181
}
182182

library/std/src/sys/windows/c.rs

-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ pub const FILE_END: DWORD = 2;
270270

271271
pub const WAIT_OBJECT_0: DWORD = 0x00000000;
272272
pub const WAIT_TIMEOUT: DWORD = 258;
273-
pub const WAIT_FAILED: DWORD = 0xFFFFFFFF;
274273

275274
pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
276275
pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;

library/std/src/sys/windows/thread.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ impl Thread {
7070
}
7171

7272
pub fn join(self) {
73-
let rc = unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE) };
74-
if rc == c::WAIT_FAILED {
75-
panic!("failed to join on thread: {}", io::Error::last_os_error());
76-
}
73+
unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE); }
7774
}
7875

7976
pub fn yield_now() {

library/std/src/thread/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1365,11 +1365,6 @@ impl<T> JoinHandle<T> {
13651365
/// [`Err`]: crate::result::Result::Err
13661366
/// [atomic memory orderings]: crate::sync::atomic
13671367
///
1368-
/// # Panics
1369-
///
1370-
/// This function may panic on some platforms if a thread attempts to join
1371-
/// itself or otherwise may create a deadlock with joining threads.
1372-
///
13731368
/// # Examples
13741369
///
13751370
/// ```

0 commit comments

Comments
 (0)