Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAI: do not prepend thread ID to backtraces from signal handler context #148

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/signals-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ static void *signal_listener(void *arg)
jl_safe_printf("\nsignal (%d): %s\n", sig, strsignal(sig));
size_t i;
for (i = 0; i < bt_size; i += jl_bt_entry_size(bt_data + i)) {
jl_print_bt_entry_codeloc(-1, bt_data + i);
jl_print_bt_entry_codeloc(sig, bt_data + i);
}
}
}
Expand Down
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 if there's no current task
if (jl_get_current_task()) {
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 if there's no current task
if (jl_get_current_task()) {
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 if there's no current task
if (jl_get_current_task()) {
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