freebsd-skq/tests/sys
John Baldwin e012fe34cb Discard the correct thread event reported for a ptrace stop.
When multiple threads wish to report a tracing event to a debugger,
both threads call ptracestop() and one thread will win the race to be
the reporting thread (p->p_xthread).  The debugger uses PT_LWPINFO
with the process ID to determine which thread / LWP is reporting an
event and the details of that event.  This event is cleared as a side
effect of the subsequent ptrace event that resumed the process
(PT_CONTINUE, PT_STEP, etc.).  However, ptrace() was clearing the
event identified by the LWP ID passed to the resume request even if
that wasn't the 'p_xthread'.  This could result in clearing an event
that had not yet been observed by the debugger and leaving the
existing event for 'p_thread' pending so that it was reported a second
time.

Specifically, if the debugger stopped due to a software breakpoint in
one thread, but then switched to another thread that was used to
resume (e.g. if the user switched to a different thread and issued a
step), the resume request (PT_STEP) cleared a pending event (if any)
for the thread being stepped.  However, the process immediately
stopped and the first thread reported it's breakpoint event a second
time.  The debugger decremented the PC for "both" breakpoint events
which resulted in the PC now pointing into the middle of an
instruction (on x86) and a SIGILL fault when the process was resumed a
second time.

To fix, always clear the pending event for 'p_xthread' when resuming a
process.  ptrace() still honors the requested LWP ID when enabling
single-stepping (PT_STEP) or setting a different PC (PT_CONTINUE).

Reported by:	GDB testsuite (gdb.threads/continue-pending-status.exp)
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D12794
2017-10-27 03:16:19 +00:00
..
acl Make test scripts under tests/... non-executable 2017-08-08 04:59:16 +00:00
aio Fix cosmetic issue with error message 2017-08-02 09:49:41 +00:00
fifo
file Make test scripts under tests/... non-executable 2017-08-08 04:59:16 +00:00
fs Chase r321920 and r321930 (dev_t being widened) 2017-08-03 03:43:41 +00:00
geom Check the exit code from fsck_ffs instead of relying on MODIFIED being in the output 2017-10-10 05:58:33 +00:00
kern Discard the correct thread event reported for a ptrace stop. 2017-10-27 03:16:19 +00:00
kqueue Make test scripts under tests/... non-executable 2017-08-08 04:59:16 +00:00
mac Make test scripts under tests/... non-executable 2017-08-08 04:59:16 +00:00
mqueue Make test scripts under tests/... non-executable 2017-08-08 04:59:16 +00:00
netinet tests/sys/netinet/fibs_test: skip selected tests when firewalls are enabled 2017-08-08 15:37:21 +00:00
netpfil pf tests: Remove temporary files 2017-10-26 20:55:33 +00:00
opencrypto aesni(4): Add support for x86 SHA intrinsics 2017-09-26 23:12:32 +00:00
pjdfstest Use MK_CHECK_USE_SANDBOX in tests/..., to deal with the fact that 2017-08-02 22:24:08 +00:00
posixshm
sys DIRDEPS_BUILD: Add some missing dirctories to the build. 2016-08-31 19:30:59 +00:00
vfs Make test scripts under tests/... non-executable 2017-08-08 04:59:16 +00:00
vm Revert r313565 -- :mmap__bad_arguments passes again after r313655 2017-02-11 20:31:57 +00:00
Makefile pf: Basic automated test using VIMAGE 2017-10-06 20:43:14 +00:00
Makefile.depend
Makefile.inc Use MK_CHECK_USE_SANDBOX in tests/..., to deal with the fact that 2017-08-02 22:24:08 +00:00