handle threads stopping while trying to get a stack trace
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
30fe3dc803
commit
feb5ba647e
1 changed files with 12 additions and 7 deletions
|
@ -285,15 +285,20 @@ void log_stacktrace (const char *name, os_threadId tid)
|
||||||
os_nanoSleep (d);
|
os_nanoSleep (d);
|
||||||
sigaction (SIGXCPU, &act, &oact);
|
sigaction (SIGXCPU, &act, &oact);
|
||||||
pthread_kill (tid.v, SIGXCPU);
|
pthread_kill (tid.v, SIGXCPU);
|
||||||
while (!os_atomic_cas32 (&log_stacktrace_flag, 2, 3))
|
while (!os_atomic_cas32 (&log_stacktrace_flag, 2, 3) && pthread_kill (tid.v, 0) == 0)
|
||||||
os_nanoSleep (d);
|
os_nanoSleep (d);
|
||||||
sigaction (SIGXCPU, &oact, NULL);
|
sigaction (SIGXCPU, &oact, NULL);
|
||||||
nn_log (~0u, "-- stack trace follows --\n");
|
if (pthread_kill (tid.v, 0) != 0)
|
||||||
strs = backtrace_symbols (log_stacktrace_stk.stk, log_stacktrace_stk.depth);
|
nn_log (~0u, "-- thread exited --\n");
|
||||||
for (i = 0; i < log_stacktrace_stk.depth; i++)
|
else
|
||||||
nn_log (~0u, "%s\n", strs[i]);
|
{
|
||||||
free (strs);
|
nn_log (~0u, "-- stack trace follows --\n");
|
||||||
nn_log (~0u, "-- end of stack trace --\n");
|
strs = backtrace_symbols (log_stacktrace_stk.stk, log_stacktrace_stk.depth);
|
||||||
|
for (i = 0; i < log_stacktrace_stk.depth; i++)
|
||||||
|
nn_log (~0u, "%s\n", strs[i]);
|
||||||
|
free (strs);
|
||||||
|
nn_log (~0u, "-- end of stack trace --\n");
|
||||||
|
}
|
||||||
os_atomic_st32 (&log_stacktrace_flag, 0);
|
os_atomic_st32 (&log_stacktrace_flag, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue