From 4a6b3c5a4dc8bf449f23a17178d1042fd5e1cabf Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 11 Apr 2019 19:18:58 -0400 Subject: [PATCH] fix #31686, segfault on invalid cmdline option (#31689) (cherry picked from commit 5ce94d8d2774019a8704e03b69ff2b99647551e5) --- src/init.c | 3 +++ test/cmdlineargs.jl | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/init.c b/src/init.c index e78dd4cfcd809..5f97d46a0b8e3 100644 --- a/src/init.c +++ b/src/init.c @@ -222,6 +222,9 @@ static void jl_close_item_atexit(uv_handle_t *handle) JL_DLLEXPORT void jl_atexit_hook(int exitcode) { + if (jl_all_tls_states == NULL) + return; + jl_ptls_t ptls = jl_get_ptls_states(); if (exitcode == 0) diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 4d5f4ba4c7539..cda7a097c3b64 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -172,7 +172,10 @@ let exename = `$(Base.julia_cmd()) --startup-file=no` # --procs @test readchomp(`$exename -q -p 2 -e "println(nworkers())"`) == "2" @test !success(`$exename -p 0`) - @test !success(`$exename --procs=1.0`) + let p = run(`$exename --procs=1.0`, wait=false) + wait(p) + @test p.exitcode == 1 && p.termsignal == 0 + end # --machine-file # this does not check that machine file works,