@@ -1152,23 +1152,30 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
11521152 jl_ptls_t * allstates = jl_atomic_load_relaxed (& jl_all_tls_states );
11531153 for (size_t i = 0 ; i < nthreads ; i ++ ) {
11541154 jl_ptls_t ptls2 = allstates [i ];
1155- if (ptls2 == NULL )
1155+ if (ptls2 == NULL ) {
11561156 continue ;
1157+ }
11571158 small_arraylist_t * live_tasks = & ptls2 -> heap .live_tasks ;
11581159 size_t n = mtarraylist_length (live_tasks );
1160+ int t_state = JL_TASK_STATE_DONE ;
11591161 jl_task_t * t = ptls2 -> root_task ;
1160- int t_state = jl_atomic_load_relaxed (& t -> _state );
1162+ if (t != NULL )
1163+ t_state = jl_atomic_load_relaxed (& t -> _state );
11611164 jl_safe_printf ("==== Thread %d created %zu live tasks\n" ,
11621165 ptls2 -> tid + 1 , n + (t_state != JL_TASK_STATE_DONE ));
11631166 if (show_done || t_state != JL_TASK_STATE_DONE ) {
11641167 jl_safe_printf (" ---- Root task (%p)\n" , ptls2 -> root_task );
1165- jl_safe_printf (" (sticky: %d, started: %d, state: %d, tid: %d)\n" ,
1166- t -> sticky , t -> started , t_state ,
1167- jl_atomic_load_relaxed (& t -> tid ) + 1 );
1168- if (t -> stkbuf != NULL )
1169- jlbacktracet (t );
1170- else
1171- jl_safe_printf (" no stack\n" );
1168+ if (t != NULL ) {
1169+ jl_safe_printf (" (sticky: %d, started: %d, state: %d, tid: %d)\n" ,
1170+ t -> sticky , t -> started , t_state ,
1171+ jl_atomic_load_relaxed (& t -> tid ) + 1 );
1172+ if (t -> stkbuf != NULL ) {
1173+ jlbacktracet (t );
1174+ }
1175+ else {
1176+ jl_safe_printf (" no stack\n" );
1177+ }
1178+ }
11721179 jl_safe_printf (" ---- End root task\n" );
11731180 }
11741181
0 commit comments