Skip to content

Commit 3b77feb

Browse files
vchuravystaticfloat
authored andcommitted
Don't segfault when running atexit before jl_threads_init
1 parent 84bf42a commit 3b77feb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/gc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,11 @@ static void schedule_all_finalizers(arraylist_t *flist) JL_NOTSAFEPOINT
481481
void jl_gc_run_all_finalizers(jl_task_t *ct)
482482
{
483483
schedule_all_finalizers(&finalizer_list_marked);
484+
// This could be run before we had a chance to setup all threads
484485
for (int i = 0;i < jl_n_threads;i++) {
485486
jl_ptls_t ptls2 = jl_all_tls_states[i];
486-
schedule_all_finalizers(&ptls2->finalizers);
487+
if (ptls2)
488+
schedule_all_finalizers(&ptls2->finalizers);
487489
}
488490
run_finalizers(ct);
489491
}

test/cmdlineargs.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
249249
@test read(`$exename -p2 -t2 -e $code`, String) == "6"
250250
end
251251

252+
# Combining --threads and invalid -C should yield a decent error
253+
@test !success(`$exename -t 2 -C invalidtarget`)
254+
252255
# --procs
253256
@test readchomp(`$exename -q -p 2 -e "println(nworkers())"`) == "2"
254257
@test !success(`$exename -p 0`)

0 commit comments

Comments
 (0)