Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 232837 - utrace: PTRACE_ATTACH of SIGSTOPped process hangs
Summary: utrace: PTRACE_ATTACH of SIGSTOPped process hangs
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: rawhide
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Roland McGrath
QA Contact: Brian Brock
Depends On:
Blocks: 233540 233852
TreeView+ depends on / blocked
Reported: 2007-03-18 17:33 UTC by Jan Kratochvil
Modified: 2007-11-30 22:11 UTC (History)
3 users (show)

Fixed In Version: kernel-2.6.23-0.204.rc8.fc8
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2007-10-04 20:23:05 UTC

Attachments (Terms of Use)
Testcase (returns OK or abort()s). (deleted)
2007-03-18 17:33 UTC, Jan Kratochvil
no flags Details
Testcase for kernel-2.6.20-1.2935.rm1.fc6: PTRACE_PEEKUSER + PTRACE_GETREGS (deleted)
2007-03-20 00:50 UTC, Jan Kratochvil
no flags Details
Testcase for this bug (deleted)
2007-03-20 00:54 UTC, Chris Moller
no flags Details
Testcase for kernel-2.6.20-1.2935.rm2.fc6: second PTRACE_ATTACH (deleted)
2007-03-20 12:26 UTC, Jan Kratochvil
no flags Details
Roland's fix. (deleted)
2007-08-30 12:30 UTC, Jan Kratochvil
no flags Details | Diff

Description Jan Kratochvil 2007-03-18 17:33:10 UTC
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
  linux-2.6.16-xen.i686 (from

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 17:33:10 UTC
Created attachment 150336 [details]
Testcase (returns OK or abort()s).

Comment 2 Roland McGrath 2007-03-19 20:06:20 UTC
Looking into it.  Someone please add this as a regression test in the frysk suite.

Comment 4 Jan Kratochvil 2007-03-20 00:50:28 UTC
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-20 00:54:04 UTC
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-20 00:56:39 UTC
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-20 02:25:46 UTC
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-20 03:11:18 UTC
Okay, original frysk testsuite test replaced with one based on attachstop2.c.

Comment 10 Jan Kratochvil 2007-03-20 12:26:47 UTC
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 15:31:35 UTC
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 05:39:01 UTC
This is long fixed and should be closed, right?

Comment 13 Jan Kratochvil 2007-08-02 14:41:35 UTC
Yes, thanks, all of its 3 sub-bugs were verified as fixed on:

Comment 14 Jan Kratochvil 2007-08-30 10:53:25 UTC
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 12:30:39 UTC
Created attachment 180921 [details]
Roland's fix.

Still testing possible regressions but basic tests look OK.

Comment 16 Jan Kratochvil 2007-08-30 14:29:22 UTC
I see no regressions on the fix in Comment 15.

Comment 17 Roland McGrath 2007-09-04 20:56:58 UTC
Current fixes are committed for the next rawhide kernel build.

Comment 18 Jan Kratochvil 2007-10-04 20:23:05 UTC
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.