Bug 705583 - ptrace: __WNOTHREAD does not work
Summary: ptrace: __WNOTHREAD does not work
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kernel
Version: 5.5.z
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Oleg Nesterov
QA Contact: Red Hat Kernel QE team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-05-17 21:55 UTC by Jan Kratochvil
Modified: 2014-02-02 14:12 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-02-02 14:12:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
testcase (4.35 KB, text/plain)
2011-05-17 21:55 UTC, Jan Kratochvil
no flags Details

Description Jan Kratochvil 2011-05-17 21:55:29 UTC
Created attachment 499480 [details]
testcase

Description of problem:
With ptraced threaded child with exited thread group leader task one should be able to waitpid somehow on it.  waitpid (PID, &status, 0) will wait till all the threads will exit.  I believe waitpid (PID, &status, __WNOTHREAD) should return status of the TID which equals PID.

Version-Release number of selected component (if applicable):
FAIL kernel-2.6.35.12-90.fc14.x86_64
FAIL kernel-smp-2.6.9-89.EL.x86_64
FAIL kernel-xen-2.6.18-238.9.1.el5.x86_64
FAIL kernel-2.6.32-71.29.1.el6.x86_64

How reproducible:
Always.

Steps to Reproduce:
gcc -o wnothread wnothread.c -Wall -g -pthread;./wnothread ;echo $?

Actual results:
1

Expected results:
0

Additional info:
I will check it into ptrace-testsuite if considered as valid bug.
It hangs GDB in some cases:
[patch] Workaround for 10970, 12702, avoid calling waitpid
http://sourceware.org/ml/gdb-patches/2011-05/msg00386.html

Comment 1 Oleg Nesterov 2011-05-18 11:00:24 UTC
(In reply to comment #0)
>
> Description of problem:
> With ptraced threaded child with exited thread group leader task one should be
> able to waitpid somehow on it.  waitpid (PID, &status, 0) will wait till all
> the threads will exit.

Yes, known oddity, I already mentioned this several times on lkml.
In particular, see the recent thread:
http://marc.info/?l=linux-kernel&m=130555999731900

    There is additional complication with the group-leader. If it is traced
    and exits, do_wait(WEXITED) doesn't work (until all threads exit) for
    the tracer. Should be changed, I think.

So yes, I believe this should be changed. But this is not trivial,
and it is not clear what exactly we should do. I'll try to do this
after the pending ptrace changes.

> I believe waitpid (PID, &status, __WNOTHREAD) should

Please note that this has nothing to do with __WNOTHREAD.
This flags means: ignore the tasks/threads cloned/traced
by our sub-threads.

Comment 2 Jan Kratochvil 2011-05-18 12:21:41 UTC
(In reply to comment #1)
> I'll try to do this after the pending ptrace changes.

OK, thanks.  Do whatever you like with this tracking Bug.


> > I believe waitpid (PID, &status, __WNOTHREAD) should
> 
> Please note that this has nothing to do with __WNOTHREAD.
> This flags means: ignore the tasks/threads cloned/traced
> by our sub-threads.

OK, thanks for the info, I will forget about __WNOTHREAD.


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