Skip to content

Commit 809057d

Browse files
committed
let freebsd truncates itself the id name
1 parent 2117ef5 commit 809057d

File tree

3 files changed

+70
-59
lines changed

3 files changed

+70
-59
lines changed

Cargo.lock

Lines changed: 65 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/shims/unix/freebsd/foreign_items.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
3030
"pthread_set_name_np" => {
3131
let [thread, name] =
3232
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
33-
// freebsd silently truncates to MAXCOMLEN (+ 1).
34-
//
35-
// ref. https://github.com/freebsd/freebsd-src/blob/314542de6d0a044640d349d68b2d1a1fe5f427ff/sys/sys/param.h#L127
36-
// ref. https://github.com/freebsd/freebsd-src/blob/314542de6d0a044640d349d68b2d1a1fe5f427ff/lib/libc/sys/thr_set_name.2#L47
37-
let max_len = usize::MAX; //20;
33+
let max_len = usize::MAX;
3834
this.pthread_setname_np(
3935
this.read_scalar(thread)?,
4036
this.read_scalar(name)?,

tests/pass-dep/shims/pthreads.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ignore-target-windows: No libc on Windows
2-
use std::ffi::{CStr, CString};
2+
use std::ffi::CStr;
3+
#[cfg(not(target_os = "freebsd"))]
4+
use std::ffi::CString;
35
use std::thread;
46

57
fn main() {
@@ -176,6 +178,7 @@ fn test_named_thread_truncation() {
176178
// Also test directly calling pthread_setname to check its return value.
177179
assert_eq!(set_thread_name(&cstr), 0);
178180
// But with a too long name it should fail.
181+
#[cfg(not(target_os = "freebsd"))]
179182
assert_ne!(set_thread_name(&CString::new(long_name).unwrap()), 0);
180183
});
181184
result.unwrap().join().unwrap();

0 commit comments

Comments
 (0)