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: kernel-2.6.20-1.2300.fc5.x86_64 linux-2.6.17.7.x86_64 (from kernel.org) linux-2.6.16-xen.i686 (from kernel.org) Version-Release number of selected component (if applicable): kernel-xen-2.6.19-1.2898.2.3.fc7.i686 kernel-2.6.20-1.2925.fc6.i586 How reproducible: Always. 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'.
Created attachment 150336 [details] Testcase (returns OK or abort()s).
Looking into it. Someone please add this as a regression test in the frysk suite.
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' failed. Aborted
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.
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
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.
Okay, original frysk testsuite test replaced with one based on attachstop2.c.
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: PTRACE_ATTACH, PTRACE_DETACH, PTRACE_ATTACH. Chris, based on your variant, also the frysk testsuite got committed this update.
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.
This is long fixed and should be closed, right?
Yes, thanks, all of its 3 sub-bugs were verified as fixed on: kernel-2.6.21-1.3228.fc7.x86_64
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) but: kernel-2.6.22.4-65.fc7.x86_64: FAIL kernel-2.6.23-0.149.rc4.fc8.x86_64: FAIL Testcase is now provided in Frysk as `frysk4217/attachstop.c'.
Created attachment 180921 [details] Roland's fix. Still testing possible regressions but basic tests look OK.
I see no regressions on the fix in Comment 15.
Current fixes are committed for the next rawhide kernel build.
Problem is no longer reproducible on: kernel-2.6.23-0.204.rc8.fc8.x86_64