public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/28471] New: Internal error on Assertion `pid != 0' on AIX
@ 2021-10-18 23:38 kadler at us dot ibm.com
  2021-10-19 18:15 ` [Bug gdb/28471] " simon.marchi at polymtl dot ca
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: kadler at us dot ibm.com @ 2021-10-18 23:38 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28471

            Bug ID: 28471
           Summary: Internal error on Assertion `pid != 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 = exited, status = 0
../../gdb/inferior.c:306: internal-error: inferior*
find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed.
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 AIX,
this seems to be implemented by aix_thread_target::wait in aix-thread.c which
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-nat.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 correct
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 that
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, however
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 comment
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 == TARGET_WAITKIND_SIGNALLED
      || status->kind == TARGET_WAITKIND_EXITED)
    return ptid;

Of course, then sync_threadlists wouldn't be called from wait. Does that
matter?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-05 21:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 23:38 [Bug gdb/28471] New: Internal error on Assertion `pid != 0' on AIX kadler at us dot ibm.com
2021-10-19 18:15 ` [Bug gdb/28471] " simon.marchi at polymtl dot ca
2021-10-19 19:17 ` kadler at us dot ibm.com
2022-08-05 21:26 ` kadler at us dot ibm.com
2022-08-05 21:44 ` simark at simark dot ca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).