public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Aditya Vidyadhar Kamath <ADITYA.VIDYADHAR.KAMATH@ibm.com>
To: Simon Marchi <simark@simark.ca>,
	Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	Joel Brobecker via Gdb-patches <gdb-patches@sourceware.org>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: RE: Fw: RE: [PATCH] Fix assert pid != 0 assertion failure in AIX
Date: Wed, 6 Jul 2022 04:25:50 +0000	[thread overview]
Message-ID: <BN8PR15MB28672EE6EB11269E99B2B254B5819@BN8PR15MB2867.namprd15.prod.outlook.com> (raw)
In-Reply-To: <e94ba62c-0437-1365-24e5-26a85837dc54@simark.ca>

[-- Attachment #1: Type: text/plain, Size: 882 bytes --]


Morning Simon.

The reason we were adding one more inferior_ptid!= 0 , condition is the previous condition in the and logic i.e. pid != inferior_ptd.pid() will satisfy as -1 is not equal to 0. [inferior_ptid is set to null before coming into wait]. So, in the next iteration since the process has exited waitpid (), will lead to ERRCHILD error though the current iteration fetched the right pid using waitpid ().

However, we get your point that inferior_ptid should not be used initially [for any condition check till we fetch the pid using waitpid ()] as it is being reset.

Please find attached our modified patch where we do a check of the inferior being in the list. I hope this solution matches to what you suggested.

[See 0001-Fix-gdb_assert-pid-0-assertion-failure-in-AIX.patch file attached to this email]

Have a great day.

Thanks and regards,
Aditya.


[-- Attachment #2: 0001-Fix-gdb_assert-pid-0-assertion-failure-in-AIX.patch --]
[-- Type: application/octet-stream, Size: 1482 bytes --]

From a1c5ab5338a5d46eab675a85c28a9b00256d395a Mon Sep 17 00:00:00 2001
From: "aditya@ibm" <aditya.vidyadhar.kamath@ibm.com>
Date: Tue, 5 Jul 2022 23:05:18 -0500
Subject: [PATCH] Fix gdb_assert (pid != 0); assertion failure in AIX

---
 gdb/aix-thread.c     | 2 ++
 gdb/rs6000-aix-nat.c | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index ecd8200b692..e5c287a3fad 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1091,6 +1091,8 @@ aix_thread_target::wait (ptid_t ptid, struct target_waitstatus *status,
   if (ptid.pid () == -1)
     return ptid_t (-1);
 
+  inferior_ptid = ptid;
+
   /* Check whether libpthdebug might be ready to be initialized.  */
   if (!pd_active && status->kind () == TARGET_WAITKIND_STOPPED
       && status->sig () == GDB_SIGNAL_TRAP)
diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c
index 8563aea313a..24071a3742f 100644
--- a/gdb/rs6000-aix-nat.c
+++ b/gdb/rs6000-aix-nat.c
@@ -525,11 +525,11 @@ rs6000_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 
 	  /* Claim it exited with unknown signal.  */
 	  ourstatus->set_signalled (GDB_SIGNAL_UNKNOWN);
-	  return inferior_ptid;
+	  return ptid_t(pid);
 	}
 
       /* Ignore terminated detached child processes.  */
-      if (!WIFSTOPPED (status) && pid != inferior_ptid.pid ())
+      if (!WIFSTOPPED (status) && find_inferior_pid(this,pid) == NULL)
 	pid = -1;
     }
   while (pid == -1);
-- 
2.31.1


  reply	other threads:[~2022-07-06  4:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29  6:58 [PATCH] Use current_inferior ()->pid for AIX Aditya Vidyadhar Kamath
2022-03-29 13:01 ` Simon Marchi
2022-03-30 13:04   ` Aditya Vidyadhar Kamath
2022-04-05 12:15     ` Aditya Vidyadhar Kamath
2022-04-05 12:47     ` Simon Marchi
2022-04-12 13:32       ` Aditya Vidyadhar Kamath
2022-04-18  6:33         ` Aditya Vidyadhar Kamath
2022-04-21 11:41         ` Aditya Vidyadhar Kamath
2022-04-21 14:51         ` Simon Marchi
     [not found]           ` <BN8PR15MB2867D6D625DD0B353C99D3A3B5DD9@BN8PR15MB2867.namprd15.prod.outlook.com>
2022-05-30 12:45             ` Simon Marchi
2022-06-10 14:47               ` Aditya Vidyadhar Kamath
2022-06-15  4:03                 ` Aditya Vidyadhar Kamath
2022-06-23 20:40                   ` Aditya Vidyadhar Kamath
2022-06-27 12:55                 ` Fw: " Aditya Vidyadhar Kamath
2022-06-27 15:11                   ` Simon Marchi
2022-07-04 19:28                   ` Simon Marchi
2022-07-06  4:25                     ` Aditya Vidyadhar Kamath [this message]
2022-07-06 17:50                       ` Fw: RE: [PATCH] Fix assert pid != 0 assertion failure in AIX Simon Marchi
2022-07-07  8:27                         ` Aditya Vidyadhar Kamath
2022-07-07 13:56                           ` Simon Marchi

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=BN8PR15MB28672EE6EB11269E99B2B254B5819@BN8PR15MB2867.namprd15.prod.outlook.com \
    --to=aditya.vidyadhar.kamath@ibm.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    --cc=simark@simark.ca \
    /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).