-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.O-neutrinoOS: QNX Neutrino, a POSIX-compatible real-time operating systemOS: QNX Neutrino, a POSIX-compatible real-time operating systemT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
I tried this code:
let name = "a".repeat(1024);
thread::Builder::new()
.name(name)
.spawn(|| {
println!("it works!");
})
.unwrap()
.join()
.unwrap();I expected to see this happen: "it works" is printed
Instead, this happened: the program panicked due to this debug assertion
rust/library/std/src/sys/unix/thread.rs
Lines 176 to 188 in 180dffb
| #[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto"))] | |
| pub fn set_name(name: &CStr) { | |
| weak! { | |
| fn pthread_setname_np( | |
| libc::pthread_t, *const libc::c_char | |
| ) -> libc::c_int | |
| } | |
| if let Some(f) = pthread_setname_np.get() { | |
| let res = unsafe { f(libc::pthread_self(), name.as_ptr()) }; | |
| debug_assert_eq!(res, 0); | |
| } | |
| } |
According to the QNX documentation the maximum length a thread name can have is _NTO_THREAD_NAME_MAX. The NTO implementation of this function should truncate the thread name like, for example, the Linux implementation does. I'll submit a fix.
Meta
I used the x86_64-pc-nto-qnx710 compilation target.
rustc --version --verbose:
rustc 1.73.0-nightly (180dffba1 2023-08-14)
binary: rustc
commit-hash: 180dffba142c47240ca0d93096ce90b9fd97c8d7
commit-date: 2023-08-14
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 17.0.0
Not including a backtrace because all the reported functions in the backtrace were <unknown>
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.O-neutrinoOS: QNX Neutrino, a POSIX-compatible real-time operating systemOS: QNX Neutrino, a POSIX-compatible real-time operating systemT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.