Skip to content

Commit

Permalink
Don't segfault when running atexit before jl_threads_init
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy authored and staticfloat committed Jun 29, 2022
1 parent 84bf42a commit 3b77feb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,11 @@ static void schedule_all_finalizers(arraylist_t *flist) JL_NOTSAFEPOINT
void jl_gc_run_all_finalizers(jl_task_t *ct)
{
schedule_all_finalizers(&finalizer_list_marked);
// This could be run before we had a chance to setup all threads
for (int i = 0;i < jl_n_threads;i++) {
jl_ptls_t ptls2 = jl_all_tls_states[i];
schedule_all_finalizers(&ptls2->finalizers);
if (ptls2)
schedule_all_finalizers(&ptls2->finalizers);
}
run_finalizers(ct);
}
Expand Down
3 changes: 3 additions & 0 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
@test read(`$exename -p2 -t2 -e $code`, String) == "6"
end

# Combining --threads and invalid -C should yield a decent error
@test !success(`$exename -t 2 -C invalidtarget`)

# --procs
@test readchomp(`$exename -q -p 2 -e "println(nworkers())"`) == "2"
@test !success(`$exename -p 0`)
Expand Down

0 comments on commit 3b77feb

Please sign in to comment.