https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b79b0c2bae128c4a48ba4f0c890b3424ddc6c4cd
commit b79b0c2bae128c4a48ba4f0c890b3424ddc6c4cd Author: Corinna Vinschen <[email protected]> Date: Wed Jan 23 21:39:19 2019 +0100 Cygwin: cygthread: set thread name before calling thread func When reusing a cygthread, the stub method fails to set the thread name to the new name. The name is only set when actually creating the thread. Fix that by moving the SetThreadName call right in front of the thread function call. Signed-off-by: Corinna Vinschen <[email protected]> Diff: --- winsup/cygwin/cygthread.cc | 4 ++-- winsup/cygwin/release/2.12.0 | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc index 4404e4a..66a3179 100644 --- a/winsup/cygwin/cygthread.cc +++ b/winsup/cygwin/cygthread.cc @@ -87,6 +87,7 @@ cygthread::stub (VOID *arg) #endif else { + SetThreadName (info->id, info->__name); info->callfunc (false); HANDLE notify = info->notify_detached; @@ -128,6 +129,7 @@ cygthread::simplestub (VOID *arg) _my_tls._ctinfo = info; info->stack_ptr = &arg; HANDLE notify = info->notify_detached; + SetThreadName (info->id, info->__name); info->callfunc (true); if (notify) SetEvent (notify); @@ -213,8 +215,6 @@ cygthread::create () this, 0, &id); if (!htobe) api_fatal ("CreateThread failed for %s - %p<%y>, %E", __name, h, id); - else - SetThreadName (GetThreadId (htobe), __name); thread_printf ("created name '%s', thread %p, id %y", __name, h, id); #ifdef DEBUGGING terminated = false; diff --git a/winsup/cygwin/release/2.12.0 b/winsup/cygwin/release/2.12.0 index af74b09..c847b91 100644 --- a/winsup/cygwin/release/2.12.0 +++ b/winsup/cygwin/release/2.12.0 @@ -77,3 +77,5 @@ Bug Fixes - Fix WEOF handling in wctype functions. Addresses: https://cygwin.com/ml/cygwin/2018-12/msg00173.html + +- Fix thread names in GDB when cygthreads get reused.
