public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Guard against killing unrelated processes in amd64-disp-step.exp
@ 2023-07-13 11:19 Rainer Orth
  2023-07-13 16:34 ` Tom Tromey
  2023-07-15 13:38 ` Andrew Burgess
  0 siblings, 2 replies; 11+ messages in thread
From: Rainer Orth @ 2023-07-13 11:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

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

When testing current gdb trunk on Solaris/amd64, the whole session was
reliably terminated by make check.  I could trace this to the following
entry in gdb.arch/amd64-disp-step/gdb.log:

FAIL: gdb.arch/amd64-disp-step.exp: add into rcx: send_signal=on: get inferior pid
Executing on target: kill -ALRM -1    (timeout = 300)
builtin_spawn -ignore SIGHUP kill -ALRM -1

If $inferior_pid doesn't refer a single process for some reason, this
kill would terminate either a process group or the whole session.

This patch avoids this by ensuring that the pid arg is positive.

Tested on amd64-pc-solaris2.11 and x86_64-pc-linux-gnu.

Ok for trunk?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-amd64-random-kill.patch --]
[-- Type: text/x-patch, Size: 671 bytes --]

diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step.exp b/gdb/testsuite/gdb.arch/amd64-disp-step.exp
--- a/gdb/testsuite/gdb.arch/amd64-disp-step.exp
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step.exp
@@ -222,7 +222,10 @@ proc rip_test { reg test_start_label tes
 	    # If we use 'signal' to send the signal GDB doesn't actually do
 	    # the displaced step, but instead just delivers the signal.
 	    set inferior_pid [get_inferior_pid]
-	    remote_exec target "kill -ALRM $inferior_pid"
+	    # Ensure that $inferior_pid refers to a single process.
+	    if {$inferior_pid > 0} {
+		remote_exec target "kill -ALRM $inferior_pid"
+	    }
 	}
 
 	gdb_test "continue" \

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

end of thread, other threads:[~2023-08-07 22:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-13 11:19 [PATCH] Guard against killing unrelated processes in amd64-disp-step.exp Rainer Orth
2023-07-13 16:34 ` Tom Tromey
2023-07-13 17:59   ` Rainer Orth
2023-07-14 17:25     ` Pedro Alves
2023-07-19 12:21       ` Rainer Orth
2023-07-15 13:38 ` Andrew Burgess
2023-07-19 12:37   ` Rainer Orth
2023-08-01 14:05     ` Rainer Orth
2023-08-02 20:56       ` Tom Tromey
2023-08-07 13:51         ` Rainer Orth
2023-08-07 22:14           ` Tom Tromey

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).