Bug 265941 - ltrace can't follow the child process.
Summary: ltrace can't follow the child process.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: ltrace
Version: 5.0
Hardware: ia64
OS: Linux
medium
high
Target Milestone: beta
: ---
Assignee: Petr Machata
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-08-30 00:49 UTC by Gui Jianfeng
Modified: 2018-10-20 02:52 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-03-18 15:00:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
This is a patch to fix this issue. (863 bytes, patch)
2007-08-30 00:49 UTC, Gui Jianfeng
no flags Details | Diff
Fix for RHEL-5 (1.01 KB, patch)
2009-02-24 17:49 UTC, Petr Machata
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2009:0380 0 normal SHIPPED_LIVE ltrace bug fix update 2009-03-18 15:00:40 UTC

Description Gui Jianfeng 2007-08-30 00:49:30 UTC
Description of problem:
if use  "ltrace -f" to trace a process which could create a new process, 
ltrace can't trace the new created process.
I have made a patch to fix this issue.

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

How reproducible:
100%


Steps to Reproduce:
#ltrace -f ./child
the child will create a new process by fork()
  
Actual results:
ltrace fails to trace the new created process, it reported as follow:
fork(Cannot attach to pid 18609: Operation not permitted
signal from wrong pid 18609 ?!?

Expected results:
ltrace shall trace the new created process.

Additional info:
traced program child.c is as follow:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>

int main()
{
        pid_t pid;
        pid = fork();
        if(pid == 0) {
                printf("This is child\n");
                sleep(1);
        } else if(pid > 0) {
                printf("This is parent\n");
        } else {
                exit(1);
        }
        exit(0);
}

Comment 1 Gui Jianfeng 2007-08-30 00:49:30 UTC
Created attachment 180181 [details]
This is a patch to fix this issue.

Comment 2 Gui Jianfeng 2008-02-02 02:54:30 UTC
This bug still exists in RHEL5.1.

Comment 17 Petr Machata 2009-02-24 17:49:08 UTC
Created attachment 333069 [details]
Fix for RHEL-5

This patch uses the same approach to solve the problem as strace does, namely that it assumes that unknown pid that occurs in follow-fork mode is a new child, and starts tracing it.

Comment 21 errata-xmlrpc 2009-03-18 15:00:46 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/RHBA-2009-0380.html


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