Faulting the TLS variable when accessed for the first time can trigger
deadlocks with internal libc lock when using the liblttng-ust-malloc
wrapper. Fix this by pre-faulting it in a library constructor, similarly
to the approach taken for all other TLS variables in lttng-ust.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
return retval;
}
+static
+void lttng_ust_fixup_malloc_nesting_tls(void)
+{
+ asm volatile ("" : : "m" (URCU_TLS(malloc_nesting)));
+}
+
__attribute__((constructor))
void lttng_ust_malloc_wrapper_init(void)
{
if (cur_alloc.calloc) {
return;
}
+ lttng_ust_fixup_malloc_nesting_tls();
/*
* Ensure the allocator is in place before the process becomes
* multithreaded.