public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/1973] New: getenv returns pointer to unallocated space.
@ 2005-12-03 12:59 marvin dot nospam at gmail dot com
2005-12-03 13:13 ` [Bug libc/1973] " marvin dot nospam at gmail dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: marvin dot nospam at gmail dot com @ 2005-12-03 12:59 UTC (permalink / raw)
To: glibc-bugs
The following code results in a segmentation faul on an AMD64.
---------------------------------
char *home_dir;
home_dir = (char *)getenv("HOME");
if (home_dir != NULL)
{
printf ("$HOME = %s\n", home_dir);
}
---------------------------------
On my system it works fine but on the system of an user of my program
(keytouch), running gentoo, it crashes.
--
Summary: getenv returns pointer to unallocated space.
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P3
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: marvin dot nospam at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/1973] getenv returns pointer to unallocated space.
2005-12-03 12:59 [Bug libc/1973] New: getenv returns pointer to unallocated space marvin dot nospam at gmail dot com
@ 2005-12-03 13:13 ` marvin dot nospam at gmail dot com
2005-12-03 16:18 ` drepper at redhat dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: marvin dot nospam at gmail dot com @ 2005-12-03 13:13 UTC (permalink / raw)
To: glibc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Version|unspecified |2.3.5
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/1973] getenv returns pointer to unallocated space.
2005-12-03 12:59 [Bug libc/1973] New: getenv returns pointer to unallocated space 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
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: drepper at redhat dot com @ 2005-12-03 16:18 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2005-12-03 16:18 -------
It of course works for everybody since otherwise all hell would break lose. If
there is some problem somewhere it must be local and you have to investigate
this yourself.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/1973] getenv returns pointer to unallocated space.
2005-12-03 12:59 [Bug libc/1973] New: getenv returns pointer to unallocated space 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
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: marvin dot nospam at gmail dot com @ 2006-01-21 17:45 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From marvin dot nospam at gmail dot com 2006-01-21 17:45 -------
I received more e-mails from people reporting this segmentation fault in my
program. I know what you are thinking ("it is a bug in your program"), but just
look at the code:
---------------------------------
void
read_plugins (KTPluginList *plugin_list)
/*
Input:
-
Output:
plugin_list - The plugins are added to this list.
Returns:
-
Description:
This function reads the plugins from the plugin directories and adds them to
plugin_list.
*/
{
char *home_dir,
*local_plugin_dir;
int local_plugin_dir_len;
read_plugin_dir (PLUGIN_DIR, plugin_list);
home_dir = (char *)getenv("HOME");
if (home_dir != NULL)
{
local_plugin_dir_len = strlen(home_dir)+strlen("/"LOCAL_PLUGIN_DIR);
local_plugin_dir = keytouch_malloc(local_plugin_dir_len+1);
strcpy (local_plugin_dir, home_dir);
strcat (local_plugin_dir, "/"LOCAL_PLUGIN_DIR);
read_plugin_dir (local_plugin_dir, plugin_list);
free (local_plugin_dir);
}
}
---------------------------------
I only received reports from people using an AMD64.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/1973] getenv returns pointer to unallocated space.
2005-12-03 12:59 [Bug libc/1973] New: getenv returns pointer to unallocated space marvin dot nospam at gmail dot com
` (2 preceding siblings ...)
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
2006-04-03 20:22 ` jakub at redhat dot com
5 siblings, 0 replies; 7+ messages in thread
From: drepper at redhat dot com @ 2006-01-21 18:04 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2006-01-21 18:04 -------
You haven't shown one shred of evidence that this is a problem in the
implementation. What is more likely:
- the implementation is buggy and millions of people are just lucky
- your one program see this problem and nobody else
There is no x86-64 specific code in the environment variable handling. Look at
your code, run it with valgrind. Determine whether you use putenv somewhere.
If yes, learn about the difference between setenv and putenv.
Until you have a self-contained program which shows the problem do not reopen
the bug. We are not going to help you debug your appication.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/1973] getenv returns pointer to unallocated space.
2005-12-03 12:59 [Bug libc/1973] New: getenv returns pointer to unallocated space marvin dot nospam at gmail dot com
` (3 preceding siblings ...)
2006-01-21 18:04 ` drepper at redhat dot com
@ 2006-04-03 18:51 ` lepinat at free dot fr
2006-04-03 20:22 ` jakub at redhat dot com
5 siblings, 0 replies; 7+ messages in thread
From: lepinat at free dot fr @ 2006-04-03 18:51 UTC (permalink / raw)
To: glibc-bugs
------- 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/1973] getenv returns pointer to unallocated space.
2005-12-03 12:59 [Bug libc/1973] New: getenv returns pointer to unallocated space marvin dot nospam at gmail dot com
` (4 preceding siblings ...)
2006-04-03 18:51 ` lepinat at free dot fr
@ 2006-04-03 20:22 ` jakub at redhat dot com
5 siblings, 0 replies; 7+ messages in thread
From: jakub at redhat dot com @ 2006-04-03 20:22 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From jakub at redhat dot com 2006-04-03 20:22 -------
You couldn't be bothered to at least compile your testcase with -Wall?
gcc would warn you about implicit declaration of getenv function.
Implicitly declared functions have int return type, but getenv realllly returns
a pointer, so in your testcase when you mistakenly don't include stdlib.h,
the resulting pointer gets upper 32 bits sign-extended from bit 31 of the
pointer.
Please don't reopen any longer and spend some time reading ISO C99.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |INVALID
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-04-03 20:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-03 12:59 [Bug libc/1973] New: getenv returns pointer to unallocated space 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
2006-04-03 20:22 ` jakub at redhat dot com
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).