public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/15607] New: Add threadsafe version of getenv()
@ 2013-06-12 14:45 hadess at hadess dot net
2013-06-12 14:55 ` [Bug libc/15607] " ondra at iuuk dot mff.cuni.cz
` (14 more replies)
0 siblings, 15 replies; 16+ messages in thread
From: hadess at hadess dot net @ 2013-06-12 14:45 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15607
Bug ID: 15607
Summary: Add threadsafe version of getenv()
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: hadess at hadess dot net
CC: drepper.fsp at gmail dot com
gnome-settings-daemon is a daemon running in a GNOME session to apply stored
settings (such as the user's preferred locale) to the running session and its
own children (such as applications launched using the media-keys).
We started hitting SEGVs somewhat randomly recently:
https://bugzilla.gnome.org/show_bug.cgi?id=701322
which are caused by races between getenv() (as used by the glibc's gettext
implementation) and setenv() (called by gnome-settings-daemon to change its own
environment).
Having getenv_r()/setenv_r() would avoid this problem and make our
implementation more straight-forward and cleaner.
[1]: https://bug701322.bugzilla-attachments.gnome.org/attachment.cgi?id=245695
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
@ 2013-06-12 14:55 ` ondra at iuuk dot mff.cuni.cz
2013-06-12 14:58 ` jakub at redhat dot com
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: ondra at iuuk dot mff.cuni.cz @ 2013-06-12 14:55 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15607
OndrejBilka <ondra at iuuk dot mff.cuni.cz> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ondra at iuuk dot mff.cuni.cz
Severity|normal |enhancement
--- Comment #1 from OndrejBilka <ondra at iuuk dot mff.cuni.cz> ---
As 2.18 is release close this will have to wait for 2.19
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() 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
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jakub at redhat dot com @ 2013-06-12 14:58 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15607
--- Comment #2 from Jakub Jelinek <jakub at redhat dot com> ---
It is certainly not straightforward or cleaner, if all the uses of getenv in
glibc are converted to a version that requires locking, there will be a
significant cost to all apps out there, not just one particular that does
something like this.
The current behavior of setenv/putenv is clearly documented.
Why exactly do you want to change environment of the running multi-threaded
process, as opposed just making sure that upon exec the executed programs will
get the desired environment?
You can use execle or execvpe functions for that.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() 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
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: hadess at hadess dot net @ 2013-06-12 15:06 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15607
--- Comment #3 from Bastien Nocera <hadess at hadess dot net> ---
(In reply to Jakub Jelinek from comment #2)
> It is certainly not straightforward or cleaner, if all the uses of getenv in
> glibc are converted to a version that requires locking, there will be a
> significant cost to all apps out there, not just one particular that does
> something like this.
> The current behavior of setenv/putenv is clearly documented.
"The implementation of getenv() is not required to be reentrant."
and
"POSIX.1-2001 does not require setenv() or unsetenv() to be reentrant."
"does not require" vs. "does not require and glibc's implementation is not".
> Why exactly do you want to change environment of the running multi-threaded
> process, as opposed just making sure that upon exec the executed programs
> will get the desired environment?
This is very early in running gnome-settings-daemon (not after minutes, or even
seconds, it's the first thing we do), but we read the stored configuration
using GSettings, which uses D-Bus. That D-Bus implementation (the one in glib)
uses threads, thus with a single call to get the configuration value, we're
using threads.
> You can use execle or execvpe functions for that.
It still makes for pretty complicated and unfriendly code.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (2 preceding siblings ...)
2013-06-12 15:06 ` hadess at hadess dot net
@ 2013-06-12 18:34 ` bugdal at aerifal dot cx
2013-06-13 8:06 ` hadess at hadess dot net
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: bugdal at aerifal dot cx @ 2013-06-12 18:34 UTC (permalink / raw)
To: glibc-bugs
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (3 preceding siblings ...)
2013-06-12 18:34 ` bugdal at aerifal dot cx
@ 2013-06-13 8:06 ` hadess at hadess dot net
2013-06-13 9:06 ` hadess at hadess dot net
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: hadess at hadess dot net @ 2013-06-13 8:06 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15607
--- Comment #5 from Bastien Nocera <hadess at hadess dot net> ---
(In reply to Rich Felker from comment #4)
<snip>
> As far as I'm concerned, this bug report should be filed against
> gnome-settings-daemon,
The bug has already been reported and fixed against gnome-settings-daemon. Did
you follow the link?
> 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.
The problem is that even if we do that, the code sucks, and it's a huge amount
of code compared to what it could be. Do you have a better way to do this?
> 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.
Per-thread env?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (4 preceding siblings ...)
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
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: hadess at hadess dot net @ 2013-06-13 9:06 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15607
--- Comment #6 from Bastien Nocera <hadess at hadess dot net> ---
I forgot to mention that we have half-a-dozen apps that have similar problems
in the typical desktop stack, including pkexec from PolicyKit, and gdm.
If at least glibc's gettext used getenv_r(), then it would certainly cause less
problems.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (5 preceding siblings ...)
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
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: neleai at seznam dot cz @ 2013-10-14 18:51 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15607
Ondrej Bilka <neleai at seznam dot cz> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |neleai at seznam dot cz
--- Comment #7 from Ondrej Bilka <neleai at seznam dot cz> ---
A setenv does locking, you could try to send a patch that adds locking to
getenv.
> 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.
A atomic part is already done. For leaking part you have problem with current
code:
/* We allocated this space; we can extend it. */
new_environ = (char **) realloc (last_environ,
(size + 2) * sizeof (char *));
which you would need to change to standard doubling of sizes.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (6 preceding siblings ...)
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
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jackie.rosen at hushmail dot com @ 2014-02-16 19:42 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15607
Jackie Rosen <jackie.rosen at hushmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jackie.rosen at hushmail dot com
--- Comment #8 from Jackie Rosen <jackie.rosen at hushmail dot com> ---
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Page where seen: http://volichat.com/adult-chat-rooms
Marked for reference. Resolved as fixed @bugzilla.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (7 preceding siblings ...)
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
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: schwab at sourceware dot org @ 2014-05-28 19:41 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15607
Andreas Schwab <schwab at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|jackie.rosen at hushmail dot com |
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (9 preceding siblings ...)
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
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 15:08 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15607
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fweimer at redhat dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (8 preceding siblings ...)
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
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 15:08 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15607
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (10 preceding siblings ...)
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
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: walters at verbum dot org @ 2015-05-14 1:22 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15607
Colin <walters at verbum dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |SUSPENDED
CC| |walters at verbum dot org
--- Comment #9 from Colin <walters at verbum dot org> ---
Rust issue on this: https://github.com/rust-lang/rust/pull/24741
Also marking SUSPENDED because I feel like that represents reality.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (11 preceding siblings ...)
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
14 siblings, 0 replies; 16+ messages in thread
From: neleai at seznam dot cz @ 2015-07-11 20:51 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15607
Ondrej Bilka <neleai at seznam dot cz> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mol at astron dot nl
--- Comment #10 from Ondrej Bilka <neleai at seznam dot cz> ---
*** Bug 13271 has been marked as a duplicate of this bug. ***
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (12 preceding siblings ...)
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
14 siblings, 0 replies; 16+ messages in thread
From: crrodriguez at opensuse dot org @ 2021-12-29 16:43 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15607
Cristian Rodríguez <crrodriguez at opensuse dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |crrodriguez at opensuse dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libc/15607] Add threadsafe version of getenv()
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() hadess at hadess dot net
` (13 preceding siblings ...)
2021-12-29 16:43 ` crrodriguez at opensuse dot org
@ 2024-01-16 16:20 ` jwakely.gcc at gmail dot com
14 siblings, 0 replies; 16+ messages in thread
From: jwakely.gcc at gmail dot com @ 2024-01-16 16:20 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15607
Jonathan Wakely <jwakely.gcc at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jwakely.gcc at gmail dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2024-01-16 16:20 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-12 14:45 [Bug libc/15607] New: Add threadsafe version of getenv() 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
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
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).