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/14/2012 12:09 PM, Florian Weimer wrote:
On 09/13/2012 12:56 PM, Stephan Bergmann wrote:
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-(

Note that the C Standard only covers getenv but no functionality to modify the environment, so the issue at hand is not relevant there.


Stephan


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