From 407937dc27362ba6f169a7b2a01e41f4ab6ede82 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 13 Apr 2021 17:24:50 -0400 Subject: [PATCH] Fix: perform lazy initialization of getenv common lib The ust-dl wrapper ends up calling into the getenv common lib very early from library constructors through use of dlopen by the tracepoint instrumentation code. This happens before the getenv common lib is explicitly initialized by liblttng-ust's contructor. Perform lazy initialization for those early use by constructor scenarios. Signed-off-by: Mathieu Desnoyers Change-Id: I9f84bb776a62e03b11db0386e267df00eb165ddd --- src/common/getenv.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/getenv.c b/src/common/getenv.c index 1909f4cf..23029508 100644 --- a/src/common/getenv.c +++ b/src/common/getenv.c @@ -64,8 +64,11 @@ char *lttng_ust_getenv(const char *name) struct lttng_env *e; bool found = false; - if (!CMM_LOAD_SHARED(lttng_ust_getenv_is_init)) - abort(); + /* + * Perform lazy initialization of lttng_ust_getenv for early use + * by library constructors. + */ + lttng_ust_getenv_init(); for (i = 0; i < LTTNG_ARRAY_SIZE(lttng_env); i++) { e = <tng_env[i]; -- 2.34.1