Fix: fix deadlock with dlopen() lttng-ust
[lttng-ust.git] / liblttng-ust / ltt-events.c
index c9d35dde199e11929e6307cfe3eb31c1dc272406..72e315ec8593bb229f83788a681f84aae3e36147 100644 (file)
@@ -10,6 +10,7 @@
 
 #define _GNU_SOURCE
 #include <stdio.h>
+#include <endian.h>
 #include <urcu/list.h>
 #include <urcu/hlist.h>
 #include <pthread.h>
@@ -21,7 +22,7 @@
 #include <stddef.h>
 #include <inttypes.h>
 #include <time.h>
-#include <lttng/ust-endian.h>
+#include <sys/prctl.h>
 #include "clock.h"
 
 #include <urcu-bp.h>
@@ -35,7 +36,6 @@
 #include <usterr-signal-safe.h>
 #include <helper.h>
 #include "error.h"
-#include "compat.h"
 
 #include "tracepoint-internal.h"
 #include "ltt-tracer.h"
@@ -44,6 +44,8 @@
 #include "../libringbuffer/shm.h"
 #include "jhash.h"
 
+#define PROCNAME_LEN 17
+
 /*
  * The sessions mutex is the centralized mutex across UST tracing
  * control and probe registration. All operations within this file are
@@ -1091,7 +1093,7 @@ int _ltt_session_metadata_statedump(struct ltt_session *session)
        struct ltt_channel *chan;
        struct ltt_event *event;
        int ret = 0;
-       char procname[LTTNG_UST_PROCNAME_LEN] = "";
+       char procname[PROCNAME_LEN] = "";
 
        if (!CMM_ACCESS_ONCE(session->active))
                return 0;
@@ -1145,8 +1147,8 @@ int _ltt_session_metadata_statedump(struct ltt_session *session)
                goto end;
 
        /* ignore error, just use empty string if error. */
-       lttng_ust_getprocname(procname);
-       procname[LTTNG_UST_PROCNAME_LEN - 1] = '\0';
+       (void) prctl(PR_GET_NAME, (unsigned long) procname, 0, 0, 0);
+       procname[PROCNAME_LEN - 1] = '\0';
        ret = lttng_metadata_printf(session,
                "env {\n"
                "       vpid = %d;\n"
@@ -1453,3 +1455,16 @@ int ltt_wildcard_disable(struct session_wildcard *wildcard)
        wildcard->enabled = 0;
        return 0;
 }
+
+/*
+ * Take the TLS "fault" in libuuid if dlopen'd, which can take the
+ * dynamic linker mutex, outside of the UST lock, since the UST lock is
+ * taken in constructors, which are called with dynamic linker mutex
+ * held.
+ */
+void lttng_fixup_event_tls(void)
+{
+       unsigned char uuid[37];
+
+       (void) uuid_generate(uuid);
+}
This page took 0.02459 seconds and 4 git commands to generate.