Skip to content

Commit 0ce67d6

Browse files
authored
Merge pull request #68 from JuliaDebug/teh/bypass_28
Avoid illegal instruction crash by circumventing ccall
2 parents 8f55669 + b492ee5 commit 0ce67d6

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/JuliaInterpreter.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,17 @@ macro interpret(arg)
981981
end
982982
end
983983

984+
function set_compiled_methods()
985+
# Work around #28 by preventing interpretation of all Base methods that have a ccall to memcpy
986+
push!(compiled_methods, which(vcat, (Vector,)))
987+
push!(compiled_methods, first(methods(Base._getindex_ra)))
988+
push!(compiled_methods, first(methods(Base._setindex_ra!)))
989+
end
990+
991+
function __init__()
992+
set_compiled_methods()
993+
end
994+
984995
include("precompile.jl")
985996
_precompile_()
986997

test/interpret.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ frame = JuliaInterpreter.enter_call(f, 3)
220220
@test JuliaInterpreter.linenumber(frame, JuliaInterpreter.JuliaProgramCounter(3)) == defline + 4
221221
@test JuliaInterpreter.linenumber(frame, JuliaInterpreter.JuliaProgramCounter(5)) == defline + 6
222222

223+
# issue #28
224+
let a = ['0'], b = ['a']
225+
@test @interpret(vcat(a, b)) == vcat(a, b)
226+
end
227+
223228
# issue #51
224229
if isdefined(Core.Compiler, :SNCA)
225230
ci = @code_lowered gcd(10, 20)

test/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ function configure_test()
141141
# in particular those that are used by the Test infrastructure
142142
cm = JuliaInterpreter.compiled_methods
143143
empty!(cm)
144+
JuliaInterpreter.set_compiled_methods()
144145
push!(cm, which(Test.eval_test, Tuple{Expr, Expr, LineNumberNode}))
145146
push!(cm, which(Test.get_testset, Tuple{}))
146147
push!(cm, which(Test.push_testset, Tuple{Test.AbstractTestSet}))

0 commit comments

Comments
 (0)