Fix: baddr deadlock with lttng-ust destructor
[lttng-ust.git] / liblttng-ust / lttng-ust-baddr.c
index aa66dccfe8a243b4e9f948644c0ec5283731e119..681ba543bcd0ad6ab417b6a04e11c983021a95b1 100644 (file)
@@ -29,8 +29,9 @@
 #include <stdint.h>
 #include <stddef.h>
 #include <stdio.h>
-#include "usterr.h"
 
+#include <usterr-signal-safe.h>
+#include "lttng-tracer-core.h"
 #include "lttng-ust-baddr.h"
 
 #define TRACEPOINT_DEFINE
@@ -90,7 +91,14 @@ int extract_soinfo_events(struct dl_phdr_info *info, size_t size, void *data)
                 * UST lock needs to be nested within dynamic loader
                 * lock.
                 */
-               ust_lock();
+               if (ust_lock()) {
+                       /*
+                        * Stop iteration on headers if need to exit.
+                        */
+                       ust_unlock();
+                       return 1;
+               }
+
                sessionsp = _lttng_get_sessions();
                cds_list_for_each_entry(session, sessionsp, node) {
                        if (session->owner != owner)
@@ -103,7 +111,6 @@ int extract_soinfo_events(struct dl_phdr_info *info, size_t size, void *data)
                                        sostat.st_mtime);
                }
                ust_unlock();
-
                /*
                 * We are only interested in the base address (lowest virtual
                 * address associated with the memory image), skip the rest
This page took 0.023691 seconds and 4 git commands to generate.