Fix: race between lttng-ust getenv() and application setenv()
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 10 Mar 2017 23:08:25 +0000 (18:08 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 20 Mar 2017 14:02:54 +0000 (10:02 -0400)
commitc452ee17f28041e29c224524e8eefe10a845adb7
tree1f32e3ce794e3139c4c592f416391aa8115fcb7e
parentab4c0f44fad08a6766e03cecac56f87e9283b6c2
Fix: race between lttng-ust getenv() and application setenv()

The LTTng-UST listener threads invoke getenv(), which can cause issues
if the application issues setenv() concurrently. This is a legitimate
use by the application because it may have a single thread and not be
aware that it runs with liblttng-ust.

Fix this by keeping our own environment variable table for the variables
we care about. Initialize this table within the lttng-ust library
constructor, when we don't race with the application.

As this thread shows:
https://sourceware.org/bugzilla/show_bug.cgi?id=5069#c10

getenv() does _not_ appear to be thread-safe if an application uses
setenv() or putenv().

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust-ctl/ustctl.c
liblttng-ust/Makefile.am
liblttng-ust/getenv.c [new file with mode: 0644]
liblttng-ust/getenv.h
liblttng-ust/lttng-clock.c
liblttng-ust/lttng-getcpu.c
liblttng-ust/lttng-ust-comm.c
liblttng-ust/lttng-ust-statedump.c
snprintf/core.c
This page took 0.026053 seconds and 4 git commands to generate.