Skip to content

Commit daa1a4b

Browse files
authored
codegen: fix unsound mark_volatile_vars implementation (JuliaLang#57131)
The previous implementation was incorrect, leading to failing to mark variables correctly. The new implementation is more conservative. This simple analysis assumes that inference has normally run or that performance doesn't matter for a particular block of code. Fixes JuliaLang#56996
1 parent 184eaf7 commit daa1a4b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/codegen.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,3 +1041,20 @@ struct Vec56937 x::NTuple{8, VecElement{Int}} end
10411041

10421042
x56937 = Ref(Vec56937(ntuple(_->VecElement(1),8)))
10431043
@test x56937[].x[1] == VecElement{Int}(1) # shouldn't crash
1044+
1045+
# issue #56996
1046+
let
1047+
()->() # trigger various heuristics
1048+
Base.Experimental.@force_compile
1049+
default_rng_orig = [] # make a value in a Slot
1050+
try
1051+
# overwrite the gc-slots in the exception branch
1052+
throw(ErrorException("This test is supposed to throw an error"))
1053+
catch ex
1054+
# destroy any values that aren't referenced
1055+
GC.gc()
1056+
# make sure that default_rng_orig value is still valid
1057+
@noinline copy!([], default_rng_orig)
1058+
end
1059+
nothing
1060+
end

0 commit comments

Comments
 (0)