From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.CeBiTec.Uni-Bielefeld.DE (smtp.CeBiTec.Uni-Bielefeld.DE [129.70.160.84]) by sourceware.org (Postfix) with ESMTPS id B2B6D3858413 for ; Wed, 19 Jul 2023 12:21:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B2B6D3858413 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cebitec.uni-bielefeld.de Received: from localhost (localhost [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 33DB2C5B46; Wed, 19 Jul 2023 14:21:13 +0200 (CEST) X-Virus-Scanned: amavisd-new at CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (smtp.cebitec.uni-bielefeld.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yPRfXLSzQAs7; Wed, 19 Jul 2023 14:21:12 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p50855614.dip0.t-ipconnect.de [80.133.86.20]) (Authenticated sender: ro) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id 9AA38C5BCE; Wed, 19 Jul 2023 14:21:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=CeBiTec.Uni-Bielefeld.DE; s=20200306; t=1689769272; bh=iKs1XoboyPgvgBHhC7kecdjnS2+WI600goQkPrBCC8s=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Jvqv9gKGxLzUPgImWWQ/K7jvnrCUJ7bM62RQ3+qQi/J/6C1jgCwfbyY/VJRZcx+u2 XgPRWRS4UThH8SVkcjr8w4pcjkCMXc9lksp1eX3vMal+FmCmcQoUacBdbaBdO7gRsd bX6VstUpgoSiiUGtw7Jbs3dJw3jQZNMRlbtmCH2U04P/EfvlTtnx69P13ymljvIXx/ bqdznMqvM348s0EHO+96zq9XU54kgnf8AOEJzZRSZ3o8bP3/I3RSobGRj5XAtsmyoN nkajfVbgiXeYLlgAh9MsVa9U6h0o5Ik/CGU22hzD4mYPCF0JQQQdzikyI1WdqFqxI5 iDMZmKHB2afrQ== From: Rainer Orth To: Pedro Alves Cc: Tom Tromey , gdb-patches@sourceware.org, Andrew Burgess Subject: Re: [PATCH] Guard against killing unrelated processes in amd64-disp-step.exp References: <87cz0vpy7g.fsf@tromey.com> Date: Wed, 19 Jul 2023 14:21:12 +0200 In-Reply-To: (Pedro Alves's message of "Fri, 14 Jul 2023 18:25:40 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1.90 (usg-unix-v) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3786.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 [] >> (/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 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 [] (/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