From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
To: Pedro Alves <pedro@palves.net>
Cc: Tom Tromey <tom@tromey.com>,
gdb-patches@sourceware.org,
Andrew Burgess <aburgess@redhat.com>
Subject: Re: [PATCH] Guard against killing unrelated processes in amd64-disp-step.exp
Date: Wed, 19 Jul 2023 14:21:12 +0200 [thread overview]
Message-ID: <ydda5vsozwn.fsf@CeBiTec.Uni-Bielefeld.DE> (raw)
In-Reply-To: <c1d0e1a6-552b-108e-ea8b-c3229b849a1e@palves.net> (Pedro Alves's message of "Fri, 14 Jul 2023 18:25:40 +0100")
Hi Pedro,
>> That's what I thought: if for whatever reason the pid turns
>> non-positive, hell breaks lose if that's passed to kill unchecked.
>>
>>> this ends up as -1, and whether a fix belongs elsewhere.
>>
>> gdb.log shows
>>
>> (gdb) PASS: gdb.arch/amd64-disp-step.exp: add into rcx: send_signal=off:
>> verify_regs: rdi expected value
>> jump test_rip_rcx
>> Continuing at 0x4015b2.
>>
>> Program terminated with signal SIGALRM, Alarm clock.
>> The program no longer exists.
>> [...]
>> [Current inferior is 1 [<null>]
>> (/vol/obj/gnu/gdb/gdb/11.4-amd64-dist/gdb/testsuite/outputs/gdb.arch/amd64-disp-step/amd64-disp-step)]
>>
>> lib/gdb.exp (get_inferior_pid) turns this <null> into -1:
>>
>
> I'm not exactly sure what is the particular problem triggering what you're seeing, but I observe a couple things:
>
> #1 - Solaris doesn't support displaced stepping. It could, the x86-64 gdbarch displaced step implementation is pretty generic.
> But they're only installed on Linux today. That's because displaced stepping is more useful with non-stop, and Solaris doesn't
> support that.
TBH, given the miserable state of the Solaris port (3000+ failures), I
haven't even looked into what features it is missing. Unless the basis
is solid, there's probably not much point in that.
> However, I tweaked the testcase to force displaced-stepping off, with:
>
> -gdb_test "set displaced-stepping on" ""
> +gdb_test "set displaced-stepping off" ""
>
> and the test still passes cleanly on Linux. So that shouldn't itself be a problem. GDB will just do the
> regular remove-breakpoint, step, re-insert breakpoint dance on Solaris.
What had me wondering is this snippet in the test's gdb.log:
(gdb) PASS: gdb.arch/amd64-disp-step.exp: add into rcx: send_signal=off: verify_regs: rdi expected value
jump test_rip_rcx
Continuing at 0x401579.
Program terminated with signal SIGALRM, Alarm clock.
The program no longer exists.
(gdb) FAIL: gdb.arch/amd64-disp-step.exp: add into rcx: send_signal=on: jump back to test_rip_rcx
[...]
(gdb) set $rdi = 0
No registers.
(gdb) inferior
[Current inferior is 1 [<null>] (/vol/obj/gnu/gdb/gdb/11.4-amd64-dist/gdb/testsuite/outputs/gdb.arch/amd64-disp-step/outputs/gdb.arch/amd64-disp-step/amd64-disp-step)]
(gdb) 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
I really don't know where the first kill -ALRM is coming from. In
amd64-disp.step.exp (rip_test), the run for rcx with signal_modes=off
succeeds, as does the jump to test_rip_rcx.
On the next iteration, with signal_modes=on, however, before set_regs
even started, the SIGALRM arrives (which should happen only *after*
the set_regs IIUC), kills the inferior, and causes the -1
inferior_pid.
Quite weird unless I'm fundamentally misunderstanding something
(highly probable).
> #2 - I did notice however something else. The .S file has this:
>
> /* test syscall */
>
> .global test_syscall
> mov $0x27,%eax /* getpid */
> test_syscall:
> syscall
> nop
> test_syscall_end:
> nop
>
> That seems like it is assuming Linux syscalls? Or is 0x27 getpid on Solaris as well? If not, I wouldn't
> be surprised if that syscall is doing something undefined. Wonder what happens if you comment out that
> code and the corresponding test in the .exp file.
0x27 is SYS_pgrpsys on Solaris, with subcodes for the likes of getpgrp,
setpgrp etc. However, disabling both test and code doesn't make a
difference for the overall outcome of the test.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
next prev parent reply other threads:[~2023-07-19 12:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 11:19 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 [this message]
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
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=ydda5vsozwn.fsf@CeBiTec.Uni-Bielefeld.DE \
--to=ro@cebitec.uni-bielefeld.de \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
--cc=tom@tromey.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).