Skip to content

Commit 9a57c9f

Browse files
committed
avoid overflow on functionality to print backtrace of safepoint straggler
1 parent f5ce249 commit 9a57c9f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/safepoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void jl_gc_wait_for_the_world(jl_ptls_t* gc_all_tls_states, int gc_n_threads)
157157
uv_mutex_unlock(&safepoint_lock);
158158
}
159159
else {
160-
const int64_t timeout = jl_options.timeout_for_safepoint_straggler_s * 1000000000; // convert to nanoseconds
160+
const int64_t timeout = jl_options.timeout_for_safepoint_straggler_s * 1000000000LL; // convert to nanoseconds
161161
int ret = 0;
162162
uv_mutex_lock(&safepoint_lock);
163163
if (!jl_atomic_load_relaxed(&ptls2->gc_state)) {

test/threads_exec.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,10 +1630,10 @@ end
16301630
program = "
16311631
function main()
16321632
t = Threads.@spawn begin
1633-
ccall(:uv_sleep, Cvoid, (Cuint,), 5000)
1633+
ccall(:uv_sleep, Cvoid, (Cuint,), 20_000)
16341634
end
16351635
# Force a GC
1636-
ccall(:uv_sleep, Cvoid, (Cuint,), 1000)
1636+
ccall(:uv_sleep, Cvoid, (Cuint,), 1_000)
16371637
GC.gc()
16381638
wait(t)
16391639
end
@@ -1644,11 +1644,13 @@ end
16441644
if isnothing(tmp_output_file)
16451645
error("Failed to open file $tmp_output_filename")
16461646
end
1647-
run(pipeline(`$(Base.julia_cmd()) --threads=4 --timeout-for-safepoint-straggler=1 -e $program`, stderr=tmp_output_file))
1648-
# Check whether we printed the straggler's backtrace
1649-
@test !isempty(read(tmp_output_filename, String))
1650-
close(tmp_output_file)
1651-
rm(tmp_output_filename)
1647+
for timeout in (1, 4, 16)
1648+
run(pipeline(`$(Base.julia_cmd()) --threads=4 --timeout-for-safepoint-straggler=$(timeout) -e $program`, stderr=tmp_output_file))
1649+
# Check whether we printed the straggler's backtrace
1650+
@test !isempty(read(tmp_output_filename, String))
1651+
close(tmp_output_file)
1652+
rm(tmp_output_filename)
1653+
end
16521654
end
16531655

16541656
end # main testset

0 commit comments

Comments
 (0)