Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid overflow on functionality to print backtrace of safepoint straggler #57579

Merged
merged 1 commit into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/safepoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void jl_gc_wait_for_the_world(jl_ptls_t* gc_all_tls_states, int gc_n_threads)
uv_mutex_unlock(&safepoint_lock);
}
else {
const int64_t timeout = jl_options.timeout_for_safepoint_straggler_s * 1000000000; // convert to nanoseconds
const int64_t timeout = jl_options.timeout_for_safepoint_straggler_s * 1000000000LL; // convert to nanoseconds
int ret = 0;
uv_mutex_lock(&safepoint_lock);
if (!jl_atomic_load_relaxed(&ptls2->gc_state)) {
Expand Down
26 changes: 14 additions & 12 deletions test/threads_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1630,25 +1630,27 @@ end
program = "
function main()
t = Threads.@spawn begin
ccall(:uv_sleep, Cvoid, (Cuint,), 5000)
ccall(:uv_sleep, Cvoid, (Cuint,), 20_000)
end
# Force a GC
ccall(:uv_sleep, Cvoid, (Cuint,), 1000)
ccall(:uv_sleep, Cvoid, (Cuint,), 1_000)
GC.gc()
wait(t)
end
main()
"
tmp_output_filename = tempname()
tmp_output_file = open(tmp_output_filename, "w")
if isnothing(tmp_output_file)
error("Failed to open file $tmp_output_filename")
end
run(pipeline(`$(Base.julia_cmd()) --threads=4 --timeout-for-safepoint-straggler=1 -e $program`, stderr=tmp_output_file))
# Check whether we printed the straggler's backtrace
@test !isempty(read(tmp_output_filename, String))
close(tmp_output_file)
rm(tmp_output_filename)
for timeout in ("1", "4", "16")
tmp_output_filename = tempname()
tmp_output_file = open(tmp_output_filename, "w")
if isnothing(tmp_output_file)
error("Failed to open file $tmp_output_filename")
end
run(pipeline(`$(Base.julia_cmd()) --threads=4 --timeout-for-safepoint-straggler=$(timeout) -e $program`, stderr=tmp_output_file))
# Check whether we printed the straggler's backtrace
@test !isempty(read(tmp_output_filename, String))
close(tmp_output_file)
rm(tmp_output_filename)
end
end

end # main testset