This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: Making getenv more multi-threading--robust?


On 09/13/2012 12:56 PM, Stephan Bergmann wrote:
[I had initially erroneously sent this to libc-help instead.]

I stumbled over this when running the LibreOffice test suite and getting
sporadic crashes in getenv(3).  It turns out that LibreOffice contains
many places that call getenv (mostly to check whether to enable one
tweak or another) at arbitrary times and from arbitrary threads, and
apparently also contains the odd call to setenv etc. to modify the
environment.

FWIW, the C11 standard appears to contain a getenv_s call (I haven't got a copy), but this seems to deal with a different issue: Apparently, there are implementations out there which free memory on putenv/setenv, invalidating pointers previously returned by getenv.


But this is suggests to me that everyone else manages getenv/environ
slightly differently from us, so we can't except much guidance from the standards. 8-(


--
Florian Weimer / Red Hat Product Security Team


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