public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "lepinat at free dot fr" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug libc/1973] getenv returns pointer to unallocated space.
Date: Mon, 03 Apr 2006 18:51:00 -0000	[thread overview]
Message-ID: <20060403185114.11864.qmail@sourceware.org> (raw)
In-Reply-To: <20051203125947.1973.marvin.nospam@gmail.com>


------- Additional Comments From lepinat at free dot fr  2006-04-03 18:51 -------
I found where the problem come from, but I can't understand why it's append,
 and I would like to know.
On the samples sended  by marvin.nospam@gmail.com

if it compiled on the 32bits mode (-m32) no problem
if it compiled on the 64bits mode (-m64) SegFault

on the samples if we add the line #include <stdlib.h> on the 64bits mode, 
the problem disappear!

---->8---->8---->8-----
# Makefile
CC:=gcc
#CFLAGS:=-enable-checking -g -O0 -v -Q -da
CFLAGS:= -g

BINARY:= test_getenv64 test_getenv64_segfault test_getenv32

all: $(BINARY)

test_getenv64_segfault: test_getenv.c
	$(CC) $(CFLAGS)  $^ -o $@

test_getenv64: test_getenv.c
	$(CC) $(CFLAGS) -DNO_FAULT $^ -o $@

test_getenv32: test_getenv.c
	$(CC) $(CFLAGS) $^ -o $@

clean:
	rm -f *.o $(BINARY) 

---->8---->8---->8-----
/* test_getenv.c */
#include <stdio.h>

#ifdef NO_FAULT
#include <stdlib.h>
#endif

main()
{
    char *home =  getenv("HOME");
    if (!home)	{
        printf("ptr=NULL\n");
    }
    else {
        printf ("path=%s\n", home);
    }
}




-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
              Alias|                            |getenv_problem
             Status|RESOLVED                    |REOPENED
 GCC target triplet|                            |x86_64
         Resolution|WORKSFORME                  |


http://sourceware.org/bugzilla/show_bug.cgi?id=1973

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


  parent reply	other threads:[~2006-04-03 18:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-03 12:59 [Bug libc/1973] New: " marvin dot nospam at gmail dot com
2005-12-03 13:13 ` [Bug libc/1973] " marvin dot nospam at gmail dot com
2005-12-03 16:18 ` drepper at redhat dot com
2006-01-21 17:45 ` marvin dot nospam at gmail dot com
2006-01-21 18:04 ` drepper at redhat dot com
2006-04-03 18:51 ` lepinat at free dot fr [this message]
2006-04-03 20:22 ` jakub at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060403185114.11864.qmail@sourceware.org \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).