Hi Ulrich, >static int >giter_count (struct thread_info *thread, void *countp) >{ > if (PD_TID (thread->ptid)) > (*(int *) countp)++; > return 0; >} >Maybe that comment is wrong about pthreaddebug not including >the main thread? Or maybe that changed between AIX versions? >In any case, something needs to be fixed here. Even if we fix it here [assuming we are succesful], in the delete_thread_1 () in thread.c we will fail to hit thread->deletable as true while we attempt delete_thread (gbuf [gi]).. Because refcount will not be 0 when we attempt to delete main thread with ptid (pid, 0, 0). {see func below} bool thread_info::deletable () const { /* If this is the current thread, or there's code out there that relies on it existing (refcount > 0) we can't delete yet. */ return refcount () == 0 && !is_current_thread (this); } I will be trying to replace the main thread instead like thread_change_ptid (proc_target, gptid, pptid) subject to a condition check that gptid.tid () == 0.. Otherwise, if it is not a main thread [gptid.tid () != 0], we can delete gbuf[gi].. We can apply this else where as well in sync_threadlists (). Let me know if we have an alternate optimal option that can delete this thread or why the solution in the above paragraph can fail.. Rest of the things I will handle. No problem. Thanks and regards, Aditya.. ________________________________ From: Ulrich Weigand Sent: 23 November 2022 22:39 To: simark@simark.ca ; Aditya Kamath1 ; gdb-patches@sourceware.org Cc: Sangamesh Mallayya Subject: Re: [PATCH] 0001-Fix-multi-thread-debug-bug-in-AIX.patch Aditya Kamath1 wrote: >Hmm. So, something is going wrong here.. >gcount = 0; > iterate_over_threads (giter_count, &gcount); > g = gbuf = XNEWVEC (struct thread_info *, gcount); > iterate_over_threads (giter_accum, &g); > qsort (gbuf, gcount, sizeof *gbuf, gcmp); Looks like this is deliberate: /* iterate_over_threads() callback for counting GDB threads. Do not count the main thread (whose tid is zero). This matches the list of threads provided by the pthreaddebug library, which does not include that main thread either, and thus allows us to compare the two lists. */ static int giter_count (struct thread_info *thread, void *countp) { if (PD_TID (thread->ptid)) (*(int *) countp)++; return 0; } Maybe that comment is wrong about pthreaddebug not including the main thread? Or maybe that changed between AIX versions? In any case, something needs to be fixed here. Bye, Ulrich