Skip to content

Commit

Permalink
Fix segfault if root task is NULL (JuliaLang#51471)
Browse files Browse the repository at this point in the history
In `jl_print_task_backtraces()`. Follow-on to
JuliaLang#51430.
  • Loading branch information
kpamnany authored and RAI CI (GitHub Action Automation) committed Nov 1, 2023
1 parent 091007e commit df89da8
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/stackwalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,23 +1169,30 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
continue;
}
jl_ptls_t ptls2 = allstates[i];
if (ptls2 == NULL)
if (ptls2 == NULL) {
continue;
}
small_arraylist_t *live_tasks = &ptls2->heap.live_tasks;
size_t n = mtarraylist_length(live_tasks);
int t_state = JL_TASK_STATE_DONE;
jl_task_t *t = ptls2->root_task;
int t_state = jl_atomic_load_relaxed(&t->_state);
if (t != NULL)
t_state = jl_atomic_load_relaxed(&t->_state);
jl_safe_printf("==== Thread %d created %zu live tasks\n",
ptls2->tid + 1, n + (t_state != JL_TASK_STATE_DONE));
if (show_done || t_state != JL_TASK_STATE_DONE) {
jl_safe_printf(" ---- Root task (%p)\n", ptls2->root_task);
jl_safe_printf(" (sticky: %d, started: %d, state: %d, tid: %d)\n",
t->sticky, t->started, t_state,
jl_atomic_load_relaxed(&t->tid) + 1);
if (t->stkbuf != NULL)
jlbacktracet(t);
else
jl_safe_printf(" no stack\n");
if (t != NULL) {
jl_safe_printf(" (sticky: %d, started: %d, state: %d, tid: %d)\n",
t->sticky, t->started, t_state,
jl_atomic_load_relaxed(&t->tid) + 1);
if (t->stkbuf != NULL) {
jlbacktracet(t);
}
else {
jl_safe_printf(" no stack\n");
}
}
jl_safe_printf(" ---- End root task\n");
}

Expand Down

0 comments on commit df89da8

Please sign in to comment.