Skip to content

Commit 128ff08

Browse files
Rollup merge of #114696 - g0djan:godjan/fix_114610, r=Mark-Simulacrum
Fix a pthread_t handle leak #114610 #114610 Ran the tests as described in https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md?plain=1#L125
2 parents 97fff1f + 9b00e5f commit 128ff08

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,20 @@ cfg_if::cfg_if! {
4747
stack_size: libc::size_t,
4848
) -> ffi::c_int;
4949
pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> ffi::c_int;
50+
pub fn pthread_detach(thread: pthread_t) -> ffi::c_int;
5051
}
5152
}
5253

5354
pub struct Thread {
5455
id: libc::pthread_t,
5556
}
57+
58+
impl Drop for Thread {
59+
fn drop(&mut self) {
60+
let ret = unsafe { libc::pthread_detach(self.id) };
61+
debug_assert_eq!(ret, 0);
62+
}
63+
}
5664
} else {
5765
pub struct Thread(!);
5866
}

0 commit comments

Comments
 (0)