Skip to content

Commit 7d336e5

Browse files
committed
fix parsing of env
1 parent 9ee610b commit 7d336e5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/threading.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,11 @@ void jl_init_threading(void)
659659
jl_n_sweepthreads = jl_options.nsweepthreads;
660660
if (jl_n_markthreads == -1) { // --gcthreads not specified
661661
if ((cp = getenv(NUM_GC_THREADS_NAME))) { // ENV[NUM_GC_THREADS_NAME] specified
662-
jl_n_markthreads = (uint64_t)strtol(cp, NULL, 10) - 1;
662+
errno = 0;
663+
jl_n_markthreads = (uint64_t)strtol(cp, &endptr, 10) - 1;
664+
if (errno != 0 || endptr == cp || nthreads <= 0)
665+
jl_n_markthreads = 0;
666+
cp = endptr;
663667
if (*cp == ',') {
664668
cp++;
665669
errno = 0;

test/cmdlineargs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
372372
end
373373

374374
withenv("JULIA_NUM_GC_THREADS" => "2,1") do
375-
@test_broken read(`$exename -e $code`, String) == "3"
375+
@test read(`$exename -e $code`, String) == "3"
376376
end
377377

378378
# --machine-file

0 commit comments

Comments
 (0)