mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-07 17:41:28 -06:00
Fix thread names being set to garbage (#3985)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
SetThreadName gets passed an std::string's c_str whose pointer gets invalidated by the assignment of g_curthread->name, resulting in broken thread names further down the line
This commit is contained in:
parent
e2f3a0f750
commit
8da0b58aaa
@ -175,7 +175,7 @@ bool AccurateSleep(const std::chrono::nanoseconds duration, std::chrono::nanosec
|
||||
// Sets the debugger-visible name of the current thread.
|
||||
void SetCurrentThreadName(const char* name) {
|
||||
if (Libraries::Kernel::g_curthread) {
|
||||
Libraries::Kernel::g_curthread->name = std::string{name};
|
||||
Libraries::Kernel::g_curthread->name = name;
|
||||
}
|
||||
SetThreadDescription(GetCurrentThread(), UTF8ToUTF16W(name).data());
|
||||
}
|
||||
@ -190,7 +190,7 @@ void SetThreadName(void* thread, const char* name) {
|
||||
#if !defined(_WIN32) || defined(_MSC_VER)
|
||||
void SetCurrentThreadName(const char* name) {
|
||||
if (Libraries::Kernel::g_curthread) {
|
||||
Libraries::Kernel::g_curthread->name = std::string{name};
|
||||
Libraries::Kernel::g_curthread->name = name;
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
pthread_setname_np(name);
|
||||
@ -219,7 +219,7 @@ void SetThreadName(void* thread, const char* name) {
|
||||
#if defined(_WIN32)
|
||||
void SetCurrentThreadName(const char*) {
|
||||
if (Libraries::Kernel::g_curthread) {
|
||||
Libraries::Kernel::g_curthread->name = std::string{name};
|
||||
Libraries::Kernel::g_curthread->name = name;
|
||||
}
|
||||
// Do Nothing on MinGW
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user