From: Ethan Jackson Date: Fri, 26 Oct 2012 19:33:01 +0000 (-0700) Subject: timeval: Fix occasional backtrace() related deadlock. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=543a550837f40e39c9f6f110e927b4c230c2d77c;p=openvswitch timeval: Fix occasional backtrace() related deadlock. Occasionally, backtrace() will deadlock in the signal handler because it does some non signal safe initialization. Specifically, it opens a shared object. As a work around, this patch forces backtrace() to run outside of a signal handler, so that future calls will perform as expected. Signed-off-by: Ethan Jackson --- diff --git a/lib/timeval.c b/lib/timeval.c index 05f1c2d3..d8539892 100644 --- a/lib/timeval.c +++ b/lib/timeval.c @@ -121,6 +121,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) {