public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bugdal at aerifal dot cx" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/15607] Add threadsafe version of getenv()
Date: Wed, 12 Jun 2013 18:34:00 -0000	[thread overview]
Message-ID: <bug-15607-131-iPHMOulslY@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-15607-131@http.sourceware.org/bugzilla/>

http://sourceware.org/bugzilla/show_bug.cgi?id=15607

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #4 from Rich Felker <bugdal at aerifal dot cx> ---
I agree with Jakub. Programs that are or may be (due to libraries that may use
threads) multi-threaded cannot modify their own environments. There's little
point in modifying your own environment anyway; for executing external
programs, the exec-family functions and posix_spawn both provide interfaces by
which you can specify your own environment for the new process image in a fully
safe manner.

Note that getenv_r could not protect against modifications to the environment
through extern char **environ, nor could setenv_r protect against reads via
environ. Thus, they could only have limited success in making environment
modification "thread-safe".

As far as I'm concerned, this bug report should be filed against
gnome-settings-daemon, not glibc, and it should be fixed by (preferably)
avoiding modification to the environment in the process itself and using the
appropriate exec-type functions, or by generating a completely new environment
and replacing extern char **environ atomically with a pointer to the new
environment.

Note that, if others do end up deeming it desirable to change glibc, the
appropriate change would be having setenv do the above-described atomic
replacement and simply leak the old environment. This would be fully safe with
no locking.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


  parent reply	other threads:[~2013-06-12 18:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-12 14:45 [Bug libc/15607] New: " hadess at hadess dot net
2013-06-12 14:55 ` [Bug libc/15607] " ondra at iuuk dot mff.cuni.cz
2013-06-12 14:58 ` jakub at redhat dot com
2013-06-12 15:06 ` hadess at hadess dot net
2013-06-12 18:34 ` bugdal at aerifal dot cx [this message]
2013-06-13  8:06 ` hadess at hadess dot net
2013-06-13  9:06 ` hadess at hadess dot net
2013-10-14 18:51 ` neleai at seznam dot cz
2014-02-16 19:42 ` jackie.rosen at hushmail dot com
2014-05-28 19:41 ` schwab at sourceware dot org
2014-06-13 15:08 ` fweimer at redhat dot com
2014-06-13 15:08 ` fweimer at redhat dot com
2015-05-14  1:22 ` walters at verbum dot org
2015-07-11 20:51 ` neleai at seznam dot cz
2021-12-29 16:43 ` crrodriguez at opensuse dot org
2024-01-16 16:20 ` jwakely.gcc at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-15607-131-iPHMOulslY@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).