Commit 4d6ac053 authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'stackdump.CxxUtils-20200704' into 'master'

CxxUtils: Make stack dumps more robust.

See merge request atlas/athena!34455
parents c82f2644 fa8e80da
......@@ -283,7 +283,7 @@ private:
static bool s_crashed;
static int s_inFatal;
static unsigned long s_lastSP;
static thread_local unsigned long s_lastSP;
static const char *s_applicationName;
static IOFD s_fatalFd;
static FatalHook s_fatalHook;
......
......@@ -150,7 +150,18 @@ int stacktracePopenFD (const char* cmd, pid_t& child_pid)
int parent_end = fds[0];
int child_end = fds[1];
#ifdef __linux__
// Use vfork rather than fork to avoid running pthread_atfork handlers.
// Openblas, for example, registers one unconditionally, but that can
// segfault if called with the program in a bad state.
// What we're doing here doesn't really comply with the restrictions
// in the vfork man page, which says that in the child after the vfork
// you can do only exec or _exit. This does in fact seem to work
// on linux, but put this within an ifdef.
child_pid = vfork();
#else
child_pid = fork();
#endif
if (child_pid == 0) {
int child_std_end = 1;
close (parent_end);
......
......@@ -125,7 +125,7 @@ bool Signal::s_crashed = false;
int Signal::s_inFatal = 0;
/** Used to switch to a raw stack dump if we crash during a backtrace. */
unsigned long Signal::s_lastSP = 0;
thread_local unsigned long Signal::s_lastSP = 0;
/** The current application name. */
const char *Signal::s_applicationName = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment