Skip to content

Commit 4114b5b

Browse files
authored
bpart: Fix a hang in a particular corner case (JuliaLang#58271)
The `jl_get_binding_partition_with_hint` version of the bpart lookup did not properly set the `max_world` of the gap, leaving it at `~(size_t)0`. Having a `gap` with that `max_world`, but with `gap.replace` set is inconsistent and ended up causing an integer overflow downstream in the computation of `expected_prev_min_world`, which looked like a concurrent modification causing an infinite retry. Fixes JuliaLang#58257
1 parent 8eeb79b commit 4114b5b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/inference.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6428,4 +6428,21 @@ global invalid_setglobal!_exct_modeling::Int
64286428
setglobal!(@__MODULE__, :invalid_setglobal!_exct_modeling, x)
64296429
end == ErrorException
64306430

6431+
# Issue #58257 - Hang in inference during BindingPartition resolution
6432+
module A58257
6433+
module B58257
6434+
using ..A58257
6435+
# World age here is N
6436+
end
6437+
using .B58257
6438+
# World age here is N+1
6439+
@eval f() = $(GlobalRef(B58257, :get!))
6440+
end
6441+
6442+
## The sequence of events is critical here.
6443+
A58257.get! # Creates binding partition in A, N+1:∞
6444+
A58257.B58257.get! # Creates binding partition in A.B, N+1:∞
6445+
Base.invoke_in_world(UInt(38678), getglobal, A58257, :get!) # Expands binding partition in A through <N
6446+
@test Base.infer_return_type(A58257.f) == typeof(Base.get!) # Attempt to lookup A.B in world age N hangs
6447+
64316448
end # module inference

0 commit comments

Comments
 (0)