Skip to content

Commit

Permalink
Add test for missing linfo root for jlcall function object
Browse files Browse the repository at this point in the history
(cherry picked from commit f95ffcd)
  • Loading branch information
yuyichao authored and tkelman committed Mar 7, 2016
1 parent 132cb20 commit fa6802d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3446,6 +3446,40 @@ end
f14339{T<:Union{}}(x::T, y::T) = 0
@test_throws MethodError f14339(1, 2)

# Make sure jlcall objects are rooted
# PR #14301
module JLCall14301

# Define f
f() = 1

let i = Any[[1.23], [2.34]]
# f() with capture variables
# Intentionally type unstable so that the dynamic dispatch will
# read the corrupted tag if the object is incorrectly GC'd.
global f() = i[1][1] * i[2][1]
end

# Another function that use f()
g() = f() * 100
# Compile it
g()

let i = 9.0
# Override f()
global f() = i + 1
end

# Make sure the old f() method is GC'd if it was not rooted properly
gc()
gc()
gc()

# Run again.
g()

end

# make sure codegen doesn't remove argument to `isa`
@noinline __g_isa_test_1(a) = push!(a,1)
function __f_isa_arg_1()
Expand Down

0 comments on commit fa6802d

Please sign in to comment.