public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	Aditya Kamath1 <Aditya.Kamath1@ibm.com>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Fix AIX thread NULL assertion failure during fork
Date: Mon, 20 Nov 2023 11:27:26 +0000	[thread overview]
Message-ID: <101f32d12e4e058fa0199bbf0b38ecfe43fcd551.camel@de.ibm.com> (raw)
In-Reply-To: <CH2PR15MB354413A2C21CA37734D2F2EBD6B4A@CH2PR15MB3544.namprd15.prod.outlook.com>

Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:

>Assume we have set detach_on_fork = on and set follow-fork-mode child.
>In AIX, on a fork () event we set our status and return our parent ptid from rs6000-aix-nat.c..
>Once the object file of the new_inferior or child process is loaded we call pd_enable () to
>set our thread target and sync our threadlists. In our sync_threadlists we have pbuf having
>our pthread library threads and gbuf having our GDB threads known to GDB core that have been
>registered. 

>While I cannot say with 100% surety that from where GDB core got this ptid and why it did not
>update to ptid_t (pid, 0, tid) , my observation post debugging is that GDB core would have got
>ptid_t(pid, 0, 0) from the rs6000-aix-nat.c file, inside the wait () where we did inform GDB
>by setting a status that this a child process belonging a parent process on a fork event.
>GDB could not change this ptid it got during the fork event, even though we changed it later
>via sync_threadlists () from aix-thread.c for the threaded event.

So here's the piece I do not fully understand: Yes, wait () inside rs6000-aix-nat.c
will set the ourstatus child_ptid to a non-threaded ptid.  But that's for a newly
created child process that should not *be* threaded at this time, right?

So how is it possible that in between wait () setting the child_ptid and infrun.c
using it to switch to the child, the child is becoming multi-threaded?  Where is
the sync_threadlists () call that makes this happen?

I'm aware that the wait () in aix-thread.c (which is the caller of the rs6000-aix-nat.c
one) does perform a pd_enable / sync_threadlists, but only on the *parent*, not
on the child.  That should happen only later.

I think we should understand better how this could have happened.

If there is a good reason why the child can already be multi-threaded, then
one option to fix this would be to switch ourstatus->child_ptid to the multi-
threaded version in the *aix-thread.c* version of wait (), just like it
switches the returned ptid.

Bye,
Ulrich


  reply	other threads:[~2023-11-20 11:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20  7:25 Aditya Kamath1
2023-11-20 11:27 ` Ulrich Weigand [this message]
2023-11-21  7:30   ` Aditya Kamath1
2023-11-21 12:17     ` Ulrich Weigand
2023-11-22 10:48       ` Aditya Kamath1
2023-11-22 11:30         ` Ulrich Weigand
2023-11-22 13:58           ` Aditya Kamath1
2023-11-22 14:14             ` Aditya Kamath1
2023-11-22 15:33               ` Ulrich Weigand
2023-11-22 16:22                 ` Aditya Kamath1
2023-11-22 18:30                   ` Ulrich Weigand
2023-11-23  6:06                     ` Aditya Kamath1

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=101f32d12e4e058fa0199bbf0b38ecfe43fcd551.camel@de.ibm.com \
    --to=ulrich.weigand@de.ibm.com \
    --cc=Aditya.Kamath1@ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    /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).