Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Dominik Karol Piątkowski" <dominik.karol.piatkowski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Dominik Grzegorzek" <dominik.grzegorzek@intel.com>,
	"Christoph Manszewski" <christoph.manszewski@intel.com>,
	"Jan Sokolowski" <jan.sokolowski@intel.com>,
	"Dominik Karol Piątkowski" <dominik.karol.piatkowski@intel.com>
Subject: [PATCH i-g-t 2/3] lib/eudebug: Fix xe_eudebug_client_stop corner case
Date: Mon, 24 Feb 2025 14:08:06 +0100	[thread overview]
Message-ID: <20250224130807.9249-3-dominik.karol.piatkowski@intel.com> (raw)
In-Reply-To: <20250224130807.9249-1-dominik.karol.piatkowski@intel.com>

After `token_signal(c->p_in, CLIENT_STOP, c->pid)`, the client is
expected to end its work and exit. By the time the waitpid() is called,
the client process may be gone already, resulting in a failed assert.

Fix it by skipping the assert in case of errno being ECHILD, meaning
the process already exited.

Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@intel.com>
---
 lib/xe/xe_eudebug.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/xe/xe_eudebug.c b/lib/xe/xe_eudebug.c
index ad8bdf68a..58acb1dea 100644
--- a/lib/xe/xe_eudebug.c
+++ b/lib/xe/xe_eudebug.c
@@ -1450,12 +1450,16 @@ void xe_eudebug_client_stop(struct xe_eudebug_client *c)
 {
 	if (c->pid) {
 		int waitstatus;
+		int ret;
 
 		xe_eudebug_client_wait_done(c);
 
 		token_signal(c->p_in, CLIENT_STOP, c->pid);
-		igt_assert_eq(waitpid(c->pid, &waitstatus, 0),
-			      c->pid);
+		ret = waitpid(c->pid, &waitstatus, 0);
+		/* process may be gone already */
+		if (!(ret == -1 && errno == ECHILD))
+			igt_assert_eq(ret, c->pid);
+
 		c->pid = 0;
 	}
 }
-- 
2.34.1


  parent reply	other threads:[~2025-02-24 13:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24 13:08 [PATCH i-g-t 0/3] tests/xe_eudebug_online: Add set-breakpoint-sigint-debugger test Dominik Karol Piątkowski
2025-02-24 13:08 ` [PATCH i-g-t 1/3] lib/eudebug: Make debugger thread SIGINTable Dominik Karol Piątkowski
2025-03-10 11:40   ` Mika Kuoppala
2025-02-24 13:08 ` Dominik Karol Piątkowski [this message]
2025-03-10 12:00   ` [PATCH i-g-t 2/3] lib/eudebug: Fix xe_eudebug_client_stop corner case Mika Kuoppala
2025-02-24 13:08 ` [PATCH i-g-t 3/3] tests/xe_eudebug_online: Add set-breakpoint-sigint-debugger test Dominik Karol Piątkowski
2025-03-10 12:23   ` Manszewski, Christoph
2025-03-11 13:54     ` Piatkowski, Dominik Karol
2025-02-25  7:47 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-02-25  7:53 ` ✗ i915.CI.BAT: failure " Patchwork
2025-02-25 13:37 ` ✗ Xe.CI.Full: " Patchwork

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=20250224130807.9249-3-dominik.karol.piatkowski@intel.com \
    --to=dominik.karol.piatkowski@intel.com \
    --cc=christoph.manszewski@intel.com \
    --cc=dominik.grzegorzek@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jan.sokolowski@intel.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