Bug 232837 - utrace: PTRACE_ATTACH of SIGSTOPped process hangs
utrace: PTRACE_ATTACH of SIGSTOPped process hangs
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
All Linux
medium Severity high
: ---
: ---
Assigned To: Roland McGrath
Brian Brock
: Regression, Reopened
Depends On:
Blocks: 233540 233852
  Show dependency treegraph
Reported: 2007-03-18 13:33 EDT by Jan Kratochvil
Modified: 2007-11-30 17:11 EST (History)
3 users (show)

See Also:
Fixed In Version: kernel-2.6.23-0.204.rc8.fc8
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-10-04 16:23:05 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Testcase (returns OK or abort()s). (992 bytes, text/x-csrc)
2007-03-18 13:33 EDT, Jan Kratochvil
no flags Details
Testcase for kernel-2.6.20-1.2935.rm1.fc6: PTRACE_PEEKUSER + PTRACE_GETREGS (1.39 KB, text/plain)
2007-03-19 20:50 EDT, Jan Kratochvil
no flags Details
Testcase for this bug (1010 bytes, text/plain)
2007-03-19 20:54 EDT, Chris Moller
no flags Details
Testcase for kernel-2.6.20-1.2935.rm2.fc6: second PTRACE_ATTACH (2.45 KB, text/plain)
2007-03-20 08:26 EDT, Jan Kratochvil
no flags Details
Roland's fix. (2.01 KB, patch)
2007-08-30 08:30 EDT, Jan Kratochvil
no flags Details | Diff

  None (edit)
Description Jan Kratochvil 2007-03-18 13:33:10 EDT
Description of problem:
utrace implementation of ptrace(2) is incompatible:
PTRACE_ATTACH on a process being stopped (by SIGSTOP) never returns.
On non-utrace kernels it returns, tested:
  linux- (from kernel.org)
  linux-2.6.16-xen.i686 (from kernel.org)

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Process A should be: kill -STOP process_A_PID
2. Process B should: ptrace (PTRACE_ATTACH, process_A_PID, NULL, NULL);
3. Process B should: waitpid (process_A_PID, &status, 0);

Actual results:
3. Process B hangs.

Expected results:
3. Process B syscall returns with: WSTOPSIG (status) == SIGSTOP

Additional info:
Testcase attached.
It was causing 12 FAILs on GDB the testcase `gdb.base/attachstop.exp'.
Comment 1 Jan Kratochvil 2007-03-18 13:33:10 EDT
Created attachment 150336 [details]
Testcase (returns OK or abort()s).
Comment 2 Roland McGrath 2007-03-19 16:06:20 EDT
Looking into it.  Someone please add this as a regression test in the frysk suite.
Comment 4 Jan Kratochvil 2007-03-19 20:50:28 EDT
Created attachment 150448 [details]
Testcase for kernel-2.6.20-1.2935.rm1.fc6: PTRACE_PEEKUSER + PTRACE_GETREGS

Tested kernel-2.6.20-1.2935.rm1.fc6 passes PTRACE_ATTACH / waitpid() but it
fails on the registers reading:
ptrace(PTRACE_ATTACH, 16984, 0, 0)	= 0
wait4(16984, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGSTOP}], 0, NULL) = 16984
ptrace(PTRACE_PEEKUSER, 16984, 8*R15, [0]) = -1 ESRCH (No such process)
ptrace(PTRACE_GETREGS, 16984, 0, 0x7fffde5e2a50) = -1 ESRCH (No such process)

Updated testcase tests also this kernel feature.
On kernel-2.6.20-1.2935.rm1.fc6.x86_64 it now fails with:
attachstop2: attachstop2.c:77: main: Assertion `(*__errno_location ()) == 0'
Comment 5 Chris Moller 2007-03-19 20:54:04 EDT
Created attachment 150449 [details]
Testcase for this bug

Having the testcase simply abort doesn't work in the frysk test suite.	This
version has been tweaked to exit(0) on pass and exit(1) on fail and it's what
I'm going to stick into the suite.
Comment 6 Jan Kratochvil 2007-03-19 20:56:39 EDT
No other regressions were found during compare of GDB-6.6-5 testsuite results:
kernel-2.6.20-1.2300.fc5.x86_64 -> kernel-2.6.20-1.2935.rm1.fc6.x86_64
Comment 7 Roland McGrath 2007-03-19 22:25:46 EDT
You also need to clean up all the asserts to be e.g. error (2, errno, ...) calls.
Do that on attachstop2.c for the suite.
Comment 8 Chris Moller 2007-03-19 23:11:18 EDT
Okay, original frysk testsuite test replaced with one based on attachstop2.c.
Comment 10 Jan Kratochvil 2007-03-20 08:26:47 EDT
Created attachment 150476 [details]
Testcase for kernel-2.6.20-1.2935.rm2.fc6: second PTRACE_ATTACH

It is sad but kernel-2.6.20-1.2935.rm2.fc6 still hangs on the sequence:

Chris, based on your variant, also the frysk testsuite got committed this
Comment 11 Jan Kratochvil 2007-03-22 11:31:35 EDT
No GDB testsuite regressions found for kernel-2.6.20-1.2300.fc5 -> 
kernel-2.6.20-1.2936.rm2.fc6 ( /mnt/brew/scratch/roland/task_684350/ ) when ran
on i686 + x86_64.
Comment 12 Roland McGrath 2007-08-02 01:39:01 EDT
This is long fixed and should be closed, right?
Comment 13 Jan Kratochvil 2007-08-02 10:41:35 EDT
Yes, thanks, all of its 3 sub-bugs were verified as fixed on:
Comment 14 Jan Kratochvil 2007-08-30 06:53:25 EDT
There is a regression for the testcase of Comment 10:
kernel-2.6.21-1.3228.fc7.x86_64: PASS (as in Comment 13 above)
kernel- FAIL
kernel-2.6.23-0.149.rc4.fc8.x86_64: FAIL

Testcase is now provided in Frysk as `frysk4217/attachstop.c'.
Comment 15 Jan Kratochvil 2007-08-30 08:30:39 EDT
Created attachment 180921 [details]
Roland's fix.

Still testing possible regressions but basic tests look OK.
Comment 16 Jan Kratochvil 2007-08-30 10:29:22 EDT
I see no regressions on the fix in Comment 15.
Comment 17 Roland McGrath 2007-09-04 16:56:58 EDT
Current fixes are committed for the next rawhide kernel build.
Comment 18 Jan Kratochvil 2007-10-04 16:23:05 EDT
Problem is no longer reproducible on: kernel-2.6.23-0.204.rc8.fc8.x86_64

Note You need to log in before you can comment on or make changes to this bug.