-
Notifications
You must be signed in to change notification settings - Fork 392
Description
pthread_setname_np
on macOS returns an integer success code: https://github.com/apple-oss-distributions/libpthread/blob/cf9e1c7e611440e511af230905be2cfefc5c6121/include/pthread/pthread.h#L509-L510
Unfortunately, the miri shim for it returns void:
miri/src/shims/unix/macos/foreign_items.rs
Lines 176 to 185 in c3d67d4
"pthread_setname_np" => { | |
let [name] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; | |
let thread = this.pthread_self()?; | |
let max_len = this.eval_libc("MAXTHREADNAMESIZE")?.to_machine_usize(this)?; | |
this.pthread_setname_np( | |
thread, | |
this.read_scalar(name)?, | |
max_len.try_into().unwrap(), | |
)?; | |
} |
This probably happened because the manpage on apple tragically has the same mistake: https://github.com/apple-oss-distributions/libpthread/blob/cf9e1c7e611440e511af230905be2cfefc5c6121/man/pthread_setname_np.3#L35
But the function truly does return int: https://github.com/apple-oss-distributions/libpthread/blob/cf9e1c7e611440e511af230905be2cfefc5c6121/src/pthread.c#L1140-L1163
This leads to false positives for UB in libstd's tests: https://github.com/rust-lang/miri-test-libstd/actions/runs/3342425264/jobs/5534636230#step:5:723