public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "kadler at us dot ibm.com" <sourceware-bugzilla@sourceware.org>
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	[thread overview]
Message-ID: <bug-28471-4717@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-10-18 23:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 23:38 kadler at us dot ibm.com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28471-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).