From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3966A3858433; Mon, 18 Oct 2021 23:38:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3966A3858433 From: "kadler at us dot ibm.com" To: gdb-prs@sourceware.org Subject: [Bug gdb/28471] New: Internal error on Assertion `pid != 0' on AIX Date: Mon, 18 Oct 2021 23:38:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 11.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kadler at us dot ibm.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Oct 2021 23:38:19 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28471 Bug ID: 28471 Summary: Internal error on Assertion `pid !=3D 0' on AIX Product: gdb Version: 11.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: kadler at us dot ibm.com Target Milestone: --- [infrun] handle_inferior_event: status->kind =3D exited, status =3D 0 ../../gdb/inferior.c:306: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid !=3D 0' fai= led. A problem internal to GDB has been detected, further debugging may prove unreliable. This was with a simple "hello world" program. The problem seems to be that target_wait is returning a ptid of pid 0. On A= IX, this seems to be implemented by aix_thread_target::wait in aix-thread.c whi= ch calls rs6000_nat_target::wait in rs6000-nat.c. While debugging, I noticed that waitpid would get a valid pid and then call waitpid again, which would print out "Child process unexpectedly missing: no such process" and return -1. I believe rs6000_nat_target::wait in rs6000-na= t.c needs similar change as commit f37e5866aa72e76f2199155fb838ffc25c78a26e, but even after making that change I'm still getting the same error. After making that change, rs6000_nat_target::wait is now returning the corr= ect pid, but aix_thread_target::wait is not. The interesting thing I noticed is that this function *never* returns or really does anything with the ptid th= at it got back. Instead it either calls pd_active or pd_update. In this case, pd_update(0) would be called, which does *something* with the pthdebug (I'm= not too familiar with these APIs) and seems to rely on using inferior_ptid, how= ever with the addition of Multi-target support in 5b6d1e4fa4fc6827c7b3f0e99ff120dfa14d65d2 switch_to_inferior_no_thread is now called. If I comment this line out, the issue goes away. Of course, the com= ment preceding it might have some words with the AIX code: /* We know that we are looking for an event in the target of inferior INF, but we don't know which thread the event might come from. As such we want to make sure that INFERIOR_PTID is reset so that none of the wait code relies on it - doing so is always a mistake. */ Seems like a lot of the aix_thread code is a mistake :D In any case, I'm not exactly sure how to fix the pd_activate / pd_update. Perhaps a ptid needs to be passed in (passing in inferior_ptid in the when = not called from wait)? The wait code could probably also use an early return when exited like in bsd-uthread.c and sol-thread.c: /* If the process is no longer alive, there's no point in figuring out the thread ID. It will fail anyway. */ if (status->kind =3D=3D TARGET_WAITKIND_SIGNALLED || status->kind =3D=3D TARGET_WAITKIND_EXITED) return ptid; Of course, then sync_threadlists wouldn't be called from wait. Does that matter? --=20 You are receiving this mail because: You are on the CC list for the bug.=