Bug 242694

Summary: utrace: PTRACE_EVENT_EXIT report gets wrong wait status for group exit
Product: [Fedora] Fedora Reporter: Magnus Vesterlund <magnus_vesterlund>
Component: kernelAssignee: Roland McGrath <roland>
Status: CLOSED CURRENTRELEASE QA Contact: Brian Brock <bbrock>
Severity: low Docs Contact:
Priority: low    
Version: 7CC: cebbert, davej
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 2.6.22.1-27.fc7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-07-24 14:38:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Test case
none
test case for second failure scenario none

Description Magnus Vesterlund 2007-06-05 14:04:18 UTC
Description of problem:

When tracing a multithreaded program that is killed by a signal using ptrace on
a Fedora kernel, I get very strange events reported by ptrace.

I have attached a test case that traces a process with two threads, sends a
SIGINT signal to the threads and prints the events that ptrace reports.

If you compile the test case with "gcc -lpthread -o ptrace-bug2 ptrace-bug2.c"
and run it on a vanilla 2.6.21.3 kernel, you get the expected messages (here
with manual annotations):

tid 2992: signal 19, ptrace event 0    SIGSTOP to parent from PTRACE_ATTACH
tid 2992: signal 5, ptrace event 3     SIGTRAP|PTRACE_EVENT_CLONE to parent
Sending SIGINT
tid 2992: signal 2, ptrace event 0     SIGINT reaches the process
Delivering SIGINT
tid 2992: signal 5, ptrace event 6     SIGTRAP|PTRACE_EVENT_EXIT to parent
tid 2993: signal 5, ptrace event 6     SIGTRAP|PTRACE_EVENT_EXIT to child
tid 2993: terminated by signal 2       Child killed by signal
tid 2992: terminated by signal 2       Parent killed by signal

If you run the test case on the Fedora kernel the signal is reported multiple
times, and you don't get and PTRACE_EVENT_EXIT events:

tid 3201: signal 19, ptrace event 0
tid 3201: signal 5, ptrace event 3
Sending SIGINT
tid 3201: signal 2, ptrace event 0
Delivering SIGINT
tid 3201: signal 2, ptrace event 0     SIGINT reported again???
Delivering SIGINT
tid 3202: signal 2, ptrace event 0     And again???
Delivering SIGINT
tid 3202: terminated by signal 2
tid 3201: terminated by signal 2

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

2.6.21-1.3194.fc7

How reproducible:

Every time.

Steps to Reproduce:

1. Compile and run the attached test case.

Actual results:

SIGINT reported multiple times, no PTRACE_EVENT_EXIT events.

Expected results:

Same ptrace events as vanilla kernel.

Additional info:

Comment 1 Magnus Vesterlund 2007-06-05 14:04:18 UTC
Created attachment 156221 [details]
Test case

Comment 2 Roland McGrath 2007-06-07 01:18:31 UTC
Reproduced on my upstream+utrace devel kernel on x86_64.

Comment 3 Roland McGrath 2007-06-14 08:13:50 UTC
I've fixed this in the utrace development code.

Comment 4 Roland McGrath 2007-06-14 08:35:40 UTC
*** Bug 242635 has been marked as a duplicate of this bug. ***

Comment 5 Roland McGrath 2007-06-14 08:37:28 UTC
Created attachment 156966 [details]
test case for second failure scenario

Bug 242635 had this second test case for the same underlying bug.

Comment 6 Magnus Vesterlund 2007-07-24 08:58:40 UTC
The fix seems to have gotten into kernel-2.6.22.1-27.fc7, at least I can't
reproduce the problem any more.