From 29b859335bf41c3037a9f5d386fef1c951259c3c Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Tue, 29 Aug 2023 20:46:57 +0100 Subject: [PATCH] std::thread::set_name exploit the return on haiku --- library/std/src/sys/unix/thread.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index 4f2d9cf36553f..b479642c2f5ef 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -204,7 +204,9 @@ impl Thread { pub fn set_name(name: &CStr) { unsafe { let thread_self = libc::find_thread(ptr::null_mut()); - libc::rename_thread(thread_self, name.as_ptr()); + let res = libc::rename_thread(thread_self, name.as_ptr()); + // We have no good way of propagating errors here, but in debug-builds let's check that this actually worked. + debug_assert_eq!(res, libc::B_OK); } }