This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: There is a mistake in the manual of GNU libc.
- From: "Takashi Nishiie" <t-nishiie at soft dot fujitsu dot com>
- To: <libc-alpha at sources dot redhat dot com>
- Date: Thu, 30 Aug 2007 10:55:38 +0900
- Subject: Re: There is a mistake in the manual of GNU libc.
- References: <004701c7ea05$63d5cac0$7c657c0a@soft.fujitsu.com>
Hi,
On adding a new environment variable, the memory block
bound to __environ is changed by realloc(). Hence calling
getenv() simultaneously with setenv() may access freed
memory block and cause SIGSEGV.
We should correct the manual, if using functions, such
as setenv(), unsetenv(), putenv(), and clearenv(), by
multi-threaded programs are not allowed.
Eample:
diff -ruN glibc-2.6.1.orig/manual/startup.texi
glibc-2.6.1/manual/startup.texi
--- glibc-2.6.1.orig/manual/startup.texi 2006-11-11 06:10:22.000000000 +0900
+++ glibc-2.6.1/manual/startup.texi 2007-08-30 10:37:23.000000000 +0900
@@ -309,9 +309,8 @@
The value of an environment variable can be accessed with the
@code{getenv} function. This is declared in the header file
-@file{stdlib.h}. All of the following functions can be safely used in
-multi-threaded programs. It is made sure that concurrent modifications
-to the environment do not lead to errors.
+@file{stdlib.h}. All the following functions other than getenv()
+can not be safely used in multi-threaded programs.
@pindex stdlib.h
@comment stdlib.h
Regards.