Skip to content

Commit

Permalink
RAI: do not prepend thread ID to backtraces from signal handler context
Browse files Browse the repository at this point in the history
  • Loading branch information
kpamnany committed Apr 18, 2024
1 parent f61f92a commit 5bcc952
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/stackwalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,14 @@ void jl_print_native_codeloc(char *pre_str, uintptr_t ip) JL_NOTSAFEPOINT
void jl_print_bt_entry_codeloc(int sig, jl_bt_element_t *bt_entry) JL_NOTSAFEPOINT
{
char sig_str[32], pre_str[64];
sig_str[0] = '\0';
sig_str[0] = pre_str[0] = '\0';
if (sig != -1) {
snprintf(sig_str, 32, "signal (%d) ", sig);
}
snprintf(pre_str, 64, "%sthread (%d) ", sig_str, jl_threadid() + 1);
// do not call jl_threadid in signal handler context
if (jl_get_pgcstack()) {
snprintf(pre_str, 64, "%sthread (%d) ", sig_str, jl_threadid() + 1);
}

if (jl_bt_is_native(bt_entry)) {
jl_print_native_codeloc(pre_str, bt_entry[0].uintptr);
Expand Down Expand Up @@ -1120,7 +1123,11 @@ static void jl_rec_backtrace(jl_task_t *t) JL_NOTSAFEPOINT
JL_DLLEXPORT void jl_gdblookup(void* ip)
{
char pre_str[64];
snprintf(pre_str, 64, "thread (%d) ", jl_threadid() + 1);
pre_str[0] = '\0';
// do not call jl_threadid in signal handler context
if (jl_get_pgcstack()) {
snprintf(pre_str, 64, "thread (%d) ", jl_threadid() + 1);
}
jl_print_native_codeloc(pre_str, (uintptr_t)ip);
}

Expand Down Expand Up @@ -1165,7 +1172,11 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
{
size_t nthreads = jl_atomic_load_acquire(&jl_n_threads);
jl_ptls_t *allstates = jl_atomic_load_relaxed(&jl_all_tls_states);
int ctid = jl_threadid() + 1;
int ctid = -1;
// do not call jl_threadid in signal handler context
if (jl_get_pgcstack()) {
ctid = jl_threadid() + 1;
}
jl_safe_printf("thread (%d) ++++ Task backtraces\n", ctid);
for (size_t i = 0; i < nthreads; i++) {
// skip GC threads since they don't have tasks
Expand Down

0 comments on commit 5bcc952

Please sign in to comment.