From: Pedro Alves <pedro@codesourcery.com>
To: Doug Evans <dje@google.com>
Cc: sergiodj@linux.vnet.ibm.com, gdb-patches@sourceware.org
Subject: Re: [RFC] mask off is-syscall bit for TRAP_IS_SYSCALL
Date: Tue, 29 Sep 2009 14:32:00 -0000 [thread overview]
Message-ID: <200909291532.29075.pedro@codesourcery.com> (raw)
In-Reply-To: <20090929124349.47188843A9@ruffy.mtv.corp.google.com>
(for those not reading the whole thread, catch syscall is
unfortunatly broken with trivial multi-threading.)
On Tuesday 29 September 2009 13:43:48, Doug Evans wrote:
> I'm not sure the filtering is done too late though.
> [One *could* do it earlier, but it seems like it could be done
> later too.]
I don't see this 0x8x signal that much different from
the extended waitstatuses, and I don't see anywhere else
other than linux_handle_extended_wait (or somewhere around it)
that would need to distinguish a syscall SIGTRAP from a regular
SIGTRAP, and yet differently from other ptrace SIGTRAPs. Take
cancel_breakpoint, for example, this seems to me that it should
already be ignoring any LWP that is stopped with a SIGTRAP due
to an ptrace event, like PTRACE_EVENT_VFORK|FORK|EXEC.
cancel_breakpoint:
- if (lp->status != 0
+ if (lp->waitstatus.kind != TARGET_WAITKIND_IGNORE
+ && lp->status != 0
&& WIFSTOPPED (lp->status) && WSTOPSIG (lp->status) == SIGTRAP
stop_wait_callback only needs to care that there's a SIGTRAP,
doesn't need to know if that SIGTRAP is a PTRACE_EVENT_FORK event
pending, just like it doesn't look like it needs to care for
TRAP_IS_SIGCALL specially.
I do see other broken calls to the core with an unfiltered 0x85,
like, e.g.,:
get_pending_status:
signo = target_signal_from_host (WSTOPSIG (lp->status));
or cases of passing a 0x85 to ptrace/kernel, like detach_callback:
if (ptrace (PTRACE_DETACH, GET_LWP (lp->ptid), 0,
WSTOPSIG (status)) < 0)
This one's quite concerning:
Catchpoint 1 (returned from syscall 202), 0x00007ffff7bd113e in __lll_lock_wait_private () from /lib/libpthread.so.0
(gdb) detach
Can't detach Thread 0x43806950 (LWP 20939): Input/output error
(gdb)
(gdb) c
Continuing.
../../src/gdb/linux-nat.c:1782: internal-error: linux_nat_resume: Assertion `lp != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
Irk!
It seems we'd want to handle syscall SIGTRAPs exactly like other
extended wait statuses --- they're all ptrace SIGTRAPs: don't ever
pass a ptrace SIGTRAP to the inferior.
Here's another somewhat related breakage:
Take the same simple multi-threaded app example as before, and do this:
(gdb) r
Starting program: /home/pedro/gdb/tests/trap_is_syscall
[Thread debugging using libthread_db enabled]
[New Thread 0x40800950 (LWP 18877)]
[New Thread 0x41001950 (LWP 18878)]
[New Thread 0x41802950 (LWP 18879)]
[New Thread 0x42003950 (LWP 18880)]
[New Thread 0x42804950 (LWP 18881)]
[New Thread 0x43005950 (LWP 18882)]
[New Thread 0x43806950 (LWP 18883)]
[New Thread 0x44007950 (LWP 18884)]
[New Thread 0x44808950 (LWP 18885)]
[New Thread 0x45009950 (LWP 18886)]
<ctrl-c>
Program received signal SIGINT, Interrupt.
0x00007ffff78ffb81 in nanosleep () from /lib/libc.so.6
(gdb) catch syscall
warning: Could not open "syscalls/amd64-linux.xml"
warning: Could not load the syscall XML file `syscalls/amd64-linux.xml'.
GDB will not be able to display syscall names.
Catchpoint 1 (any syscall)
(gdb) c
Continuing.
[Switching to Thread 0x45009950 (LWP 18886)]
Catchpoint 1 (call to syscall 35), 0x00007ffff78ffb81 in nanosleep () from /lib/libc.so.6
<a couple more continues>
Now, delete the catchpoint, while some LWPs have a pending syscall event to report:
(gdb) del 1
(gdb) c
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 0x44808950 (LWP 18885)]
0x00007ffff78ffb81 in nanosleep () from /lib/libc.so.6
(gdb)
This case does need to be filtered later, it seems to me.
> btw, I'm seeing lots of "syscall 0" (presumably restarted system calls).
> I hacked another patch to save the the syscall number so that the user
> wouldn't see syscall 0, but maybe the thing to do is record the
> fact that the syscall got restarted and report that to the user?
> [I'm assuming the 0's I see are indeed restarted syscalls.]
Hmmm, haven't seen this one yet.
--
Pedro Alves
next prev parent reply other threads:[~2009-09-29 14:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-29 12:45 Doug Evans
2009-09-29 14:32 ` Pedro Alves [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-09-28 19:39 Doug Evans
2009-09-28 19:46 ` Sérgio Durigan Júnior
2009-09-28 19:58 ` Pedro Alves
2009-09-28 23:27 ` Pedro Alves
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=200909291532.29075.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=sergiodj@linux.vnet.ibm.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