From 34bcc8e8ff73725e160e630be147a295bd5c7a13 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 3 Apr 2022 17:03:59 -0400 Subject: [PATCH 1/2] Don't cast thread name to an integer for prctl libc::prctl and the prctl definitions in glibc, musl, and the kernel headers are C variadic functions. Therefore, all the arguments (except for the first) are untyped. It is only the Linux man page which says that prctl takes 4 unsigned long arguments. I have no idea why it says this. In any case, the upshot is that we don't need to cast the pointer to an integer and confuse Miri. --- library/std/src/sys/unix/thread.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index bb4e4ee9aa75b..967d3b2bd9fe4 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -122,7 +122,7 @@ impl Thread { // pthread wrapper only appeared in glibc 2.12, so we use syscall // directly. unsafe { - libc::prctl(PR_SET_NAME, name.as_ptr() as libc::c_ulong, 0, 0, 0); + libc::prctl(PR_SET_NAME, name.as_ptr(), 0, 0, 0); } } From e8a6f53af82b43f79ae36de139cb6867a7bc73ee Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Wed, 6 Apr 2022 17:11:50 -0400 Subject: [PATCH 2/2] Change trailing prctl arguments to c_ulong --- library/std/src/sys/unix/thread.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index 967d3b2bd9fe4..d191e1fe7a650 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -122,7 +122,13 @@ impl Thread { // pthread wrapper only appeared in glibc 2.12, so we use syscall // directly. unsafe { - libc::prctl(PR_SET_NAME, name.as_ptr(), 0, 0, 0); + libc::prctl( + PR_SET_NAME, + name.as_ptr(), + 0 as libc::c_ulong, + 0 as libc::c_ulong, + 0 as libc::c_ulong, + ); } }