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 Thu, 2012-09-13 at 12:56 +0200, Stephan Bergmann wrote:
> Though getenv is generally known to not be thread-safe, glibc already 
> contains measures to make concurrent calls to setenv etc. thread-safe, 
> so I wonder whether something like the attached 
> 0001-Prevent-races-when-getenv-walks-__environ-while-sete.patch would 
> make sense.  While this would not solve my problems with 
> (cross-platform) LibreOffice, it would help prevent glibc getenv crashes 
> as demonstrated by the little program in the patch's commit message.

If different threads frequently call getenv, this could decrease
performance due to cache misses and/or contention on the lock.

*If* this is problem that we face in practice, then we can likely
synchronize differently in getenv (i.e., return consistent information
without any special ordering guarantees wrt setenv calls).  In that
case, I can help with that.

Torvald


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