Skip to content

Don't wake the log task after its condition is finalized - #3385

Merged
maleadt merged 1 commit into
mainfrom
tb/logging-null-handle
Oct 14, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/logging-null-handle

Conversation

@maleadt

@maleadt maleadt commented Oct 13, 2026

Copy link
Copy Markdown
Member

At exit, Julia runs the remaining finalizers newest first. The AsyncCondition that delivers queued library messages can therefore be finalized before objects whose finalizers still call into a library and make it log, e.g. cuDNN descriptors created before cuDNN.enable_logging(). enqueue_log then passed the condition's null handle to uv_async_send and Julia segfaulted. Skip the wake-up instead, since nothing can deliver the message at that point.

On main this no longer triggers with the reporter's example, because #3318 defers descriptor destruction from finalizers, but any library callback during exit finalization still crashes. The regression test reproduces it with a plain finalizer in a subprocess.

Fixes #3379

At exit, Julia runs the remaining finalizers newest first, so the AsyncCondition that
delivers queued library messages can be finalized before objects whose finalizers still
call into a library, e.g. cuDNN descriptors created before `cuDNN.enable_logging()`.
When the library then logs, `enqueue_log` passed the condition's null handle to
`uv_async_send` and Julia segfaulted. Skip the wake-up instead.

Fixes #3379
@maleadt maleadt added the bugfix label Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

CUDA.jl Benchmarks

Details
Benchmark suite Current: b327b1f Previous: 212af1e Ratio
array/accumulate/Float32/1d 64609 ns 65317 ns 0.99
array/accumulate/Float32/dims=1 208848 ns 208785 ns 1.00
array/accumulate/Float32/dims=1L 231528 ns 231362 ns 1.00
array/accumulate/Float32/dims=2 92902 ns 92936 ns 1.00
array/accumulate/Float32/dims=2L 4414669 ns 4414162 ns 1.00
array/accumulate/Int64/1d 106567 ns 106759 ns 1.00
array/accumulate/Int64/dims=1 223934 ns 224599 ns 1.00
array/accumulate/Int64/dims=1L 404020 ns 404787 ns 1.00
array/accumulate/Int64/dims=2 112184 ns 112409 ns 1.00
array/accumulate/Int64/dims=2L 5303946 ns 5304186 ns 1.00
array/broadcast 10940 ns 11284 ns 0.97
array/broadcast launch 7079.75 ns 7388.5 ns 0.96
array/construct 943.1739130434783 ns 966.34375 ns 0.98
array/copy 16888 ns 17285 ns 0.98
array/copyto!/cpu_to_gpu 208837 ns 206598 ns 1.01
array/copyto!/gpu_to_cpu 241314 ns 240623 ns 1.00
array/copyto!/gpu_to_gpu 8884 ns 8960 ns 0.99
array/iteration/findall/bool 49071 ns 49634 ns 0.99
array/iteration/findall/int 71391 ns 70475 ns 1.01
array/iteration/findfirst/bool 115883 ns 116138 ns 1.00
array/iteration/findfirst/int 113280 ns 113800 ns 1.00
array/iteration/findmin/1d 67294 ns 66791 ns 1.01
array/iteration/findmin/2d 69284 ns 67619 ns 1.02
array/iteration/logical 53091 ns 52939 ns 1.00
array/iteration/scalar 60314 ns 61169 ns 0.99
array/permutedims/2d 47958 ns 48338 ns 0.99
array/permutedims/3d 45229 ns 45659 ns 0.99
array/permutedims/4d 49014 ns 48717 ns 1.01
array/random/rand/Float32 10985 ns 11309 ns 0.97
array/random/rand/Int64 18397 ns 18964 ns 0.97
array/random/rand!/Float32 8230.666666666666 ns 8438.333333333334 ns 0.98
array/random/rand!/Int64 16192 ns 16530 ns 0.98
array/random/randn/Float32 34136 ns 34478 ns 0.99
array/random/randn!/Float32 24998 ns 25061 ns 1.00
array/reductions/mapreduce/Float32/1d 50008 ns 50429 ns 0.99
array/reductions/mapreduce/Float32/dims=1 44093 ns 43107 ns 1.02
array/reductions/mapreduce/Float32/dims=1L 74118 ns 72540 ns 1.02
array/reductions/mapreduce/Float32/dims=2 46005 ns 44886 ns 1.02
array/reductions/mapreduce/Float32/dims=2L 74633 ns 73143 ns 1.02
array/reductions/mapreduce/Int64/1d 51444 ns 51687 ns 1.00
array/reductions/mapreduce/Int64/dims=1 46127 ns 45426 ns 1.02
array/reductions/mapreduce/Int64/dims=1L 113606 ns 112852 ns 1.01
array/reductions/mapreduce/Int64/dims=2 46287 ns 46742 ns 0.99
array/reductions/mapreduce/Int64/dims=2L 101842 ns 100935 ns 1.01
array/reductions/reduce/Float32/1d 50776 ns 50222 ns 1.01
array/reductions/reduce/Float32/dims=1 44427 ns 43415 ns 1.02
array/reductions/reduce/Float32/dims=1L 74170 ns 73141 ns 1.01
array/reductions/reduce/Float32/dims=2 46199 ns 44957 ns 1.03
array/reductions/reduce/Float32/dims=2L 75139 ns 73558 ns 1.02
array/reductions/reduce/Int64/1d 51973 ns 52140 ns 1.00
array/reductions/reduce/Int64/dims=1 46913 ns 45836 ns 1.02
array/reductions/reduce/Int64/dims=1L 113548 ns 113326 ns 1.00
array/reductions/reduce/Int64/dims=2 46644 ns 46418 ns 1.00
array/reductions/reduce/Int64/dims=2L 101461 ns 100281 ns 1.01
array/reverse/1d 23408 ns 23893 ns 0.98
array/reverse/1dL 129738 ns 129747 ns 1.00
array/reverse/1dL_inplace 71114 ns 71493 ns 0.99
array/reverse/1d_inplace 13045 ns 13317 ns 0.98
array/reverse/2d 23325 ns 23517 ns 0.99
array/reverse/2dL 81828 ns 82043 ns 1.00
array/reverse/2dL_inplace 71695 ns 71810 ns 1.00
array/reverse/2d_inplace 15628 ns 15843 ns 0.99
array/sorting/1d 753167 ns 751635 ns 1.00
array/sorting/2d 195755 ns 195077 ns 1.00
array/sorting/by 932460 ns 928868 ns 1.00
cuda/graph/capture 42257 ns 41925 ns 1.01
cuda/graph/eager 39871 ns 42248 ns 0.94
cuda/graph/launch 13923 ns 14019 ns 0.99
cuda/synchronization/context/auto 7932 ns 7997.75 ns 0.99
cuda/synchronization/context/blocking 908.8235294117648 ns 895.8 ns 1.01
cuda/synchronization/context/nonblocking 7893 ns 7974.75 ns 0.99
cuda/synchronization/stream/auto 832.8 ns 886.9019607843137 ns 0.94
cuda/synchronization/stream/blocking 766.2477876106195 ns 780.3818181818182 ns 0.98
cuda/synchronization/stream/nonblocking 7836.333333333333 ns 7939.75 ns 0.99
integration/byval/reference 147631 ns 147881 ns 1.00
integration/byval/slices=1 148637 ns 148971 ns 1.00
integration/byval/slices=2 290364 ns 290729 ns 1.00
integration/byval/slices=3 432045 ns 432610 ns 1.00
integration/cudadevrt 105159 ns 105333 ns 1.00
integration/volumerhs 9609694 ns 9609784 ns 1.00
kernel/indexing 11564 ns 11657 ns 0.99
kernel/indexing_checked 12215 ns 12194 ns 1.00
kernel/launch 2256.222222222222 ns 2508 ns 0.90
kernel/occupancy 904.953488372093 ns 878.25 ns 1.03
kernel/rand 15171 ns 15391 ns 0.99
latency/import 4769772213 ns 4759695773 ns 1.00
latency/precompile 5396089777 ns 5390889215 ns 1.00
latency/ttfp 5249709853 ns 5247400815 ns 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@maleadt
maleadt merged commit 02ddd06 into main Oct 14, 2026
15 of 18 checks passed
@maleadt
maleadt deleted the tb/logging-null-handle branch October 14, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segfault at exit when cuDNN.enable_logging() is called after cuDNN was already used

1 participant