Replace most uses of assert by ovs_assert.
[sliver-openvswitch.git] / lib / timeval.c
index 05f1c2d..d91305c 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <config.h>
 #include "timeval.h"
-#include <assert.h>
 #include <errno.h>
 #if HAVE_EXECINFO_H
 #include <execinfo.h>
@@ -121,6 +120,16 @@ time_init(void)
     }
     inited = true;
 
+    /* The implementation of backtrace() in glibc does some one time
+     * initialization which is not signal safe.  This can cause deadlocks if
+     * run from the signal handler.  As a workaround, force the initialization
+     * to happen here. */
+    if (HAVE_EXECINFO_H) {
+        void *bt[1];
+
+        backtrace(bt, ARRAY_SIZE(bt));
+    }
+
     memset(traces, 0, sizeof traces);
 
     if (HAVE_EXECINFO_H && CACHE_TIME) {
@@ -721,7 +730,7 @@ backtrace_cb(struct unixctl_conn *conn,
 {
     struct ds ds = DS_EMPTY_INITIALIZER;
 
-    assert(HAVE_EXECINFO_H && CACHE_TIME);
+    ovs_assert(HAVE_EXECINFO_H && CACHE_TIME);
     format_backtraces(&ds, 0);
     unixctl_command_reply(conn, ds_cstr(&ds));
     ds_destroy(&ds);