ref:9e1f089e1fc7dcbb3dd655e35157e2b633ad402a

fix(linux/freebsd): truncate thread names to 15 characters (#5527)

SHA: 9e1f089e1fc7dcbb3dd655e35157e2b633ad402a
Author: Conn O'Griofa <connogriofa@gmail.com>
Date: 2026-08-20 03:31
Parents: 6ad5f97
4 files changed +10 -7
Type
src/platform/common.h +1 −1
@@ -949,6 +949,6 @@
*
* @param name Human-readable name to assign.
*/
void set_thread_name(const std::string &name);
void set_thread_name(std::string_view name);
void enable_mouse_keys();
src/platform/linux/misc.cpp +4 −2
@@ -521,8 +521,10 @@
}
}
void set_thread_name(const std::string &name) {
pthread_setname_np(pthread_self(), name.c_str());
void set_thread_name(std::string_view name) {
// Truncate name to fit in Linux/FreeBSD kernel's 16 byte limit
std::string tr_name {name.substr(0, 15)};
pthread_setname_np(pthread_self(), tr_name.c_str());
}
/**
src/platform/macos/misc.mm +3 −2
@@ -252,8 +252,9 @@
pthread_set_qos_class_self_np(mac_priority, 0);
}
void set_thread_name(const std::string &name) {
pthread_setname_np(name.c_str());
void set_thread_name(std::string_view name) {
std::string thread_name {name};
pthread_setname_np(thread_name.c_str());
}
void enable_mouse_keys() {
src/platform/windows/misc.cpp +2 −2
@@ -1130,8 +1130,8 @@
}
}
void set_thread_name(const std::string &name) {
std::wstring wname = utf_utils::from_utf8(name);
void set_thread_name(std::string_view name) {
std::wstring wname = utf_utils::from_utf8(std::string {name});
HRESULT hr = SetThreadDescription(GetCurrentThread(), wname.c_str());
if (FAILED(hr)) {
BOOST_LOG(error) << "SetThreadDescription failed: " << hr;