From 41755d1690c9dd111d20a6695f970108c1efec38 Mon Sep 17 00:00:00 2001 From: Havard Eidnes Date: Fri, 13 Oct 2023 13:35:11 +0000 Subject: [PATCH] NetBSD's mod.rs: fix cpuid_t definition. ...in particular for 32-bit CPUs / ports, such as 32-bit arm, i386, and powerpc. In the C header files on NetBSD, this is defined as typedef unsigned long cpuid_t; and on ILP32 CPUs, that ends up being a 32-bit quantity. Defining this as a 64-bit type wrecks havoc on our 32-bit ports when e.g. _cpuset_isset() is used (as was introduced with 1.72.0), causing immediate SEGV due to NULL pointer de-reference, as observed in https://github.com/rust-lang/rust/pull/116665 So, instead, define it as ::c_ulong, and let the CPU-specific type definitions take care of the sizing. --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index eae246fa887a1..18a00ae38607e 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -10,7 +10,7 @@ type __pthread_spin_t = __cpu_simple_lock_nv_t; pub type vm_size_t = ::uintptr_t; // FIXME: deprecated since long time pub type lwpid_t = ::c_uint; pub type shmatt_t = ::c_uint; -pub type cpuid_t = u64; +pub type cpuid_t = ::c_ulong; pub type cpuset_t = _cpuset; pub type pthread_spin_t = ::c_uchar; pub type timer_t = ::c_int;