🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #2433

Re: pthreads + execv causes gdb to get confused

#2433
From: Srini
Date: Thu, 21 Mar 2002 07:18
76 lines
3488 bytes
Hi,
I am also facing the same problem.
I am using RH 7.2 on IA32 box, with kernel 2.4.7-10.
U can reproduce (is it a bug????) this as follows. Use the test case given below.
[root@nadda randd]# cat test.c
#include <stdlib.h>

int main(int argc, char **argv) {
    char *p=getenv("MYTEST");

    printf("start of mytest\n");
    if (p==NULL) {
        printf("p is null\n");
        putenv("MYTEST=yes");
        printf("calling execvp %s\n",argv[0]);
        execvp(argv[0], argv);
    } else {
        printf("p = %s\n",p);
    }
    printf("rest of program...\n");
    printf("end of mytest\n");
    exit(0);
}
[root@nadda randd]# gcc -g -o test -lpthread test.c
[root@nadda randd]# gdb test
GNU gdb Red Hat Linux (5.1-1)
Copyright 2001 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) r
Starting program: /home/ansriniv/randd/test
[New Thread 1024 (LWP 4162)]
start of mytest
p is null
calling execvp /home/ansriniv/randd/test
Cannot find user-level thread for LWP 4162: generic error
(gdb) c
Continuing.
Cannot find thread 1024: generic error
(gdb)



doylep@eecg.toronto.edu (Patrick Doyle) wrote in message news:<699e3226.0203191209.403ad50e@posting.google.com>...
> Hi.  I hope this is helpful...
> 
> When debugging a program that uses pthreads, a call to execv causes
> gdb to get mighty confused:
> 
> (gdb) run
> Starting program: abc
> [New Thread 1024 (LWP 8440)]
> Breakpoint 2 (...)
> 736             execvp(argv[0], argv);
> (gdb) cont
> Continuing.
> Cannot find user-level thread for LWP 8445: generic error
> (gdb) bt
> Cannot find thread 1024: generic error
> (gdb) quit
> The program is running.  Exit anyway? (y or n) y
> Cannot find thread 1024: generic error
> (gdb) [5]   Terminated              gdb abc
> 
> [6]+  Stopped                 gdb abc
> [bash]$ kill %
> 
> [6]+  Stopped                 gdb abc
> [bash]$
> [6]+  Terminated              gdb abc
> [bash]$
> 
> This is Red Hat 7.2 and GNU gdb 20020225.
Technical Details
Message-ID: <2f641791.0203202318.8fb3aff@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news-hub.siol.net!zur.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!not-for-mail
References: <699e3226.0203191209.403ad50e@posting.google.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,9a65a43ad455212b
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 2002-03-20 23:18:31 PST
x-uunet-gateway: chi6sosrv13.alter.net from bug-gdb to gnu.gdb.bug; Thu, 21 Mar 2002 07:18:29 GMT
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news-hub.siol.net!zur.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!not-for-mail
From: srinivas_av@rediffmail.com (Srini)
Subject: Re: pthreads + execv causes gdb to get confused
Date: 20 Mar 2002 23:18:10 -0800
Organization: http://groups.google.com/
Message-ID: <2f641791.0203202318.8fb3aff@posting.google.com>
References: <699e3226.0203191209.403ad50e@posting.google.com>
NNTP-Posting-Host: 202.135.142.194
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1016695090 23599 127.0.0.1 (21 Mar 2002 07:18:10 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 21 Mar 2002 07:18:10 GMT
Approved: bug-gdb-request@mail.gnu.org
Newsgroups: gnu.gdb.bug
Sender: bug-gdb-request@mail.gnu.org
Lines: 76