Skip to content

Commit cee03ad

Browse files
kpamnanyRAI CI (GitHub Action Automation)
authored and
RAI CI (GitHub Action Automation)
committed
RAI: do not prepend thread ID to backtraces from signal handler context
Also show the signal number when we have it.
1 parent af9459c commit cee03ad

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Diff for: src/signals-unix.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ static void *signal_listener(void *arg)
11071107
jl_safe_printf("\nsignal (%d): %s\n", sig, strsignal(sig));
11081108
size_t i;
11091109
for (i = 0; i < signal_bt_size; i += jl_bt_entry_size(signal_bt_data + i)) {
1110-
jl_print_bt_entry_codeloc(-1, signal_bt_data + i);
1110+
jl_print_bt_entry_codeloc(sig, signal_bt_data + i);
11111111
}
11121112
}
11131113
}

Diff for: src/stackwalk.c

+15-4
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,14 @@ static void jl_print_debugloc(const char *pre_str, jl_debuginfo_t *debuginfo, jl
757757
void jl_print_bt_entry_codeloc(int sig, jl_bt_element_t *bt_entry) JL_NOTSAFEPOINT
758758
{
759759
char sig_str[32], pre_str[64];
760-
sig_str[0] = '\0';
760+
sig_str[0] = pre_str[0] = '\0';
761761
if (sig != -1) {
762762
snprintf(sig_str, 32, "signal (%d) ", sig);
763763
}
764-
snprintf(pre_str, 64, "%sthread (%d) ", sig_str, jl_threadid() + 1);
764+
// do not call jl_threadid if there's no current task
765+
if (jl_get_current_task()) {
766+
snprintf(pre_str, 64, "%sthread (%d) ", sig_str, jl_threadid() + 1);
767+
}
765768

766769
if (jl_bt_is_native(bt_entry)) {
767770
jl_print_native_codeloc(pre_str, bt_entry[0].uintptr);
@@ -1373,7 +1376,11 @@ JL_DLLEXPORT jl_record_backtrace_result_t jl_record_backtrace(jl_task_t *t, jl_b
13731376
JL_DLLEXPORT void jl_gdblookup(void* ip)
13741377
{
13751378
char pre_str[64];
1376-
snprintf(pre_str, 64, "thread (%d) ", jl_threadid() + 1);
1379+
pre_str[0] = '\0';
1380+
// do not call jl_threadid if there's no current task
1381+
if (jl_get_current_task()) {
1382+
snprintf(pre_str, 64, "thread (%d) ", jl_threadid() + 1);
1383+
}
13771384
jl_print_native_codeloc(pre_str, (uintptr_t)ip);
13781385
}
13791386

@@ -1433,7 +1440,11 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
14331440

14341441
size_t nthreads = jl_atomic_load_acquire(&jl_n_threads);
14351442
jl_ptls_t *allstates = jl_atomic_load_relaxed(&jl_all_tls_states);
1436-
int ctid = jl_threadid() + 1;
1443+
int ctid = -1;
1444+
// do not call jl_threadid if there's no current task
1445+
if (jl_get_current_task()) {
1446+
ctid = jl_threadid() + 1;
1447+
}
14371448
jl_safe_printf("thread (%d) ++++ Task backtraces\n", ctid);
14381449
for (size_t i = 0; i < nthreads; i++) {
14391450
jl_ptls_t ptls2 = allstates[i];

0 commit comments

Comments
 (0)