This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gdb/1427: C's stdlib getenv("PWD") with wrong return value inside GDB


The following reply was made to PR gdb/1427; it has been noted by GNATS.

From: Daniel Jacobowitz <drow@mvista.com>
To: lucaslm@dep.fem.unicamp.br
Cc: gdb-gnats@sources.redhat.com, lucas.martini@ic.unicamp.br
Subject: Re: gdb/1427: C's stdlib getenv("PWD") with wrong return value inside GDB
Date: Thu, 23 Oct 2003 15:27:31 -0400

 On Thu, Oct 23, 2003 at 07:12:39PM -0000, lucaslm@dep.fem.unicamp.br wrote:
 > 
 > >Number:         1427
 > >Category:       gdb
 > >Synopsis:       C's stdlib getenv("PWD") with wrong return value inside GDB
 > >Confidential:   no
 > >Severity:       serious
 > >Priority:       medium
 > >Responsible:    unassigned
 > >State:          open
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Thu Oct 23 19:18:00 UTC 2003
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     lucaslm@dep.fem.unicamp.br
 > >Release:        GNU gdb 6.0 (LINUX)
 > >Organization:
 > >Environment:
 > Linux guinness 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux
 > gcc (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
 > This GDB was configured as "i686-pc-linux-gnu"...
 > >Description:
 > Calls to getenv("PWD") to get the current directory from the
 > environment variables inside GDB return "pwd" instead of 
 > NULL or the correct working directory.
 > Calls to getenv("PATH") for example, or any other 
 > environment variable I tested work just fine.
 > "Show env PWD" inside GDB DOES show the correct working 
 > directory.
 > The call works fine outside GDB.
 > Problem also occurs on GNU gdb 5.1 in SUN4SOL systems
 > Problem does NOT occur in GNU gdb 2003-09-20-cvs (cygwin-special)
 > >How-To-Repeat:
 > The following test program reproduces the problem in my 
 > systems. Note the PATH should print ok, while PWD would 
 > print only "pwd".
 > 
 > #include <stdio.h>
 > #include <stdlib.h>
 > 
 > int main(int argc, char** argv) {
 >   
 >   char* pwd[255];
 >   char* path[5000];
 > 		
 >   *pwd = getenv("PWD");
 >   printf("PWD is: %s\n", *pwd);
 > 
 >   *path = getenv("PATH");
 >   printf("PATH is: %s\n", *path);
 > 
 >   return 0;
 > }
 > >Fix:
 > Good luck, I have no idea. =)
 
 GDB starts a shell to start your program.  It's most likely a problem
 with one of your shell's dot-scripts (.profile et cetera).
 
 -- 
 Daniel Jacobowitz
 MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]