Bug 120462

Summary: strace -f -p on multithreaded program does not notice existing threads
Product: [Fedora] Fedora Reporter: Hrunting Johnson <hrunting>
Component: straceAssignee: Roland McGrath <roland>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 2Keywords: FutureFeature
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-04-16 23:27:27 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:

Description Hrunting Johnson 2004-04-08 23:25:49 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6)
Gecko/20040206 Firefox/0.8

Description of problem:
strace cannot trace multithreaded programs.  It will only trace the
parent thread, which is often not a thread doing any real work. 
strace is basically useless on multithreaded programs.

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

How reproducible:
Always

Steps to Reproduce:
1.start multithreaded process
2.strace it
3.
    

Actual Results:  Only trace from parent thread is shown.

Expected Results:  Either strace needs a way to trace individual
threads or it should show all of the switching between threads.

Additional info:

I have no clue how this would work.  It's only a problem with NPTL
programs that have the same PID for every thread.  There is no
workaround, but I see no easy solution, either.

Comment 1 Roland McGrath 2004-04-08 23:56:25 UTC
Are you using -f?  If you are using strace -f and not seeing all
threads, for both NPTL and linuxthreads flavors, then please report a
specific test scenario with all necessary sources.

Comment 2 Hrunting Johnson 2004-04-09 00:01:22 UTC
Yes, I am.  The specific multi-threaded program I'm trying to strace
is called Cyclone
(http://archive.highwinds-software.com/builds/index.html).  The
software is proprietary, but the evaluation license is free.  When I
do an strace -f -p <pid>, all I get is the result of the primary
process.  I know the process is doing more because it's pushing out
over 100Mbps of traffic.

Comment 3 Roland McGrath 2004-04-09 00:07:54 UTC
It is important to include in any bug report all the details of how
you are using the program.  You did not say you were using -p to
attach to a running program, which is a critical detail.

strace -f attaches to new threads as they are created.  When using -p,
you are still only attaching to one thread (the initial thread) and if
you use -f then you also see new threads created once you are already
tracing.  strace -p has never before attached to several threads
automatically, for either NPTL or linuxthreads.  It is now easy enough
to implement that for NPTL threads due to 2.6 kernel support in /proc.
That seems like a worthwhile enhancement, but lack of it is not really
a bug as such.  I will implement this upstream, and a new strace rpm
might make it in before the FC2 release. 

Comment 4 Hrunting Johnson 2004-04-09 12:18:55 UTC
Well, right.  The problem was before that you could do strace -f -p on
an individual thread because threads got their own PIDs so there
wasn't any need to be able to trace from the master, but I should've
filed a better bug report.

Thanks for grabbing it.

Comment 5 Roland McGrath 2004-04-16 22:13:24 UTC
I've made this enhancement upstream.

Comment 6 Jay Turner 2004-09-02 03:32:26 UTC
An errata 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 the 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/RHBA-2004-338.html