Hi Ulrich and community, Please find attached the patch. >Two issues: >- Please only use current_inferior() in the ::mourn_inferior path. > In the ::detach path you still should use the passed-in "inf". > (This means pd_enable/disable still should get an "inf" argument.) This is done. I misunderstood the previous email. Apologise for the same. So now the inferior argument is passed in pd_enable () and pd_disable () so that we are good and do not cause the memory leak and pid != 0 assertion failure.. Outputs before and after patch remain same as the previous email. Kindly check in this version. Have a nice day ahead. Appreciate your patience. Thanks and regards, Aditya. From: Ulrich Weigand Date: Tuesday, 2 May 2023 at 7:36 PM To: gdb-patches@sourceware.org , Aditya Kamath1 Cc: Sangamesh Mallayya Subject: Re: [Patch] Fix Assertion pid 0 failure in AIX while running gdb.threads/foll-fork-other-thread Aditya Kamath1 wrote: >>Ah, right. There's indeed no inf argument (unfortunately), but you can >>just use "current_inferior ()" instead. This is guaranteed to be >>set correctly at this point. > >This makes it easy. Thanks Ulrich. It fixes the issue and no memory leaks. >Kindly push this small patch if there are no further changes. Two issues: - Please only use current_inferior() in the ::mourn_inferior path. In the ::detach path you still should use the passed-in "inf". (This means pd_enable/disable still should get an "inf" argument.) - Your patch adds: data = get_thread_data_helper_for_pid (current_inferior ()->pid); where get_thread_data_helper_for_pid does: inferior *inf = find_inferior_pid (current_inferior ()->process_target (), pid); return get_aix_thread_variables_data (inf); This seems a bit silly (and inefficient) - if you already have an "inf", you should just use get_aix_thread_variables_data directly. Bye, Ulrich