Bug 481199

Summary: waitpid() reports stopped process more than once
Product: Red Hat Enterprise Linux 5 Reporter: Denys Vlasenko <dvlasenk>
Component: kernelAssignee: Vitaly Mayatskikh <vmayatsk>
Status: CLOSED ERRATA QA Contact: Red Hat Kernel QE team <kernel-qe>
Severity: medium Docs Contact:
Priority: urgent    
Version: 5.3CC: dhoward, dzickus, emcnabb, jan.kratochvil, jpirko, jplans, ltroan, mgahagan, tao, tis
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-02 08:13:13 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:
Bug Depends On:    
Bug Blocks: 486945    
Attachments:
Description Flags
Kernel patch: do not report stops more than once none

Description Denys Vlasenko 2009-01-22 18:16:21 UTC
Created attachment 329724 [details]
Kernel patch: do not report stops more than once

Forking off a kernel bug discovered while working on a strace improvement (bug 478419).

Oleg Nesterov's comment from bug 478419:
===============
simple test case:

int main(void)
{
        int pid, status;

        pid = fork();
        if (!pid) {
                ptrace(PTRACE_TRACEME, 0, 0, 0);
                return kill(getpid(), SIGSTOP);
        }

        wait(&status);
        printf("status: %04X\n", status);

        ptrace(PTRACE_SYSCALL, pid, 0, SIGSTOP);

        wait(&status);
        printf("status: %04X\n", status);

        wait(&status);
        printf("status: %04X\n", status);

        return 0;
}

ouput:

    status: 137F
    status: 137F
    status: 007F

Imho bug. Fedora is fine, and I bet upstream too.
===============

In fact, in the above example wait() will report SIGSTOPed process infinitely many times (if you put wait() in the loop), but it should block on the second call.

Attached patch seems to fix it. Run tested.

Comment 1 Denys Vlasenko 2009-02-03 16:05:57 UTC
Created a testcase for it, waitpid-double-report:

http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/tests/ptrace-tests/tests/waitpid-double-report.c?cvsroot=systemtap

Comment 3 RHEL Program Management 2009-02-16 15:44:05 UTC
Updating PM score.

Comment 4 RHEL Program Management 2009-02-17 15:31:27 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 7 Don Zickus 2009-04-27 15:59:15 UTC
in kernel-2.6.18-141.el5
You can download this test kernel from http://people.redhat.com/dzickus/el5

Please do NOT transition this bugzilla state to VERIFIED until our QE team
has sent specific instructions indicating when to do so.  However feel free
to provide a comment indicating that this fix has been verified.

Comment 12 errata-xmlrpc 2009-09-02 08:13:13 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2009-1243.html

Comment 14 Oleg Nesterov 2011-02-02 18:52:22 UTC
*** Bug 456342 has been marked as a duplicate of this bug. ***