Skip to content

Commit

Permalink
fix #31965, bug in interpreter stacktraces and `jl_code_requires_comp…
Browse files Browse the repository at this point in the history
…iler` (#31967)

(cherry picked from commit e3afef0)
  • Loading branch information
JeffBezanson authored and KristofferC committed May 9, 2019
1 parent 7c09900 commit 339911f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion base/stacktraces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ using Base.Meta
is_loc_meta(expr, kind) = isexpr(expr, :meta) && length(expr.args) >= 1 && expr.args[1] === kind
function lookup(ip::Base.InterpreterIP)
if ip.code isa Core.MethodInstance && ip.code.def isa Method
codeinfo = ip.code.inferred
codeinfo = ip.code.uninferred
func = ip.code.def.name
file = ip.code.def.file
line = ip.code.def.line
Expand Down
2 changes: 1 addition & 1 deletion src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ static void expr_attributes(jl_value_t *v, int *has_intrinsics, int *has_defs) J
jl_module_t *mod = jl_globalref_mod(f);
jl_sym_t *name = jl_globalref_name(f);
if (jl_binding_resolved_p(mod, name)) {
jl_binding_t *b = jl_get_module_binding(mod, name);
jl_binding_t *b = jl_get_binding(mod, name);
if (b && b->value && b->constp)
called = b->value;
}
Expand Down
2 changes: 1 addition & 1 deletion test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function choosetests(choices = [])
"errorshow", "sets", "goto", "llvmcall", "llvmcall2", "grisu",
"some", "meta", "stacktraces", "docs",
"misc", "threads", "stress",
"enums", "cmdlineargs", "int",
"enums", "cmdlineargs", "int", "interpreter",
"checked", "bitset", "floatfuncs", "precompile",
"boundscheck", "error", "ambiguous", "cartesian", "osutils",
"channels", "iostream", "secretbuffer", "specificity",
Expand Down
16 changes: 0 additions & 16 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6801,22 +6801,6 @@ struct T29145{A,B}
end
@test_throws TypeError T29145()

# interpreted but inferred/optimized top-level expressions with vars
let code = """
while true
try
this_is_undefined_29213
ed = 0
break
finally
break
end
end
print(42)
"""
@test read(`$(Base.julia_cmd()) --startup-file=no --compile=min -e $code`, String) == "42"
end

# issue #29175
function f29175(tuple::T) where {T<:Tuple}
prefix::Tuple{T.parameters[1:end-1]...} = tuple[1:length(T.parameters)-1]
Expand Down
32 changes: 32 additions & 0 deletions test/interpreter.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Test

# interpreted but inferred/optimized top-level expressions with vars
let code = """
while true
try
this_is_undefined_29213
ed = 0
break
finally
break
end
end
print(42)
"""
@test read(`$(Base.julia_cmd()) --startup-file=no --compile=min -e $code`, String) == "42"
end

let code = "Threads.atomic_add!(Threads.Atomic{Int}(40), 2)"
@test read(`$(Base.julia_cmd()) --startup-file=no --compile=min -E $code`, String) == "40\n"
end

let p = Pipe(),
c = pipeline(`$(Base.julia_cmd()) --startup-file=no --compile=min -E 'error()'`, stderr=p)
proc = run(c, wait=false)
readline(p)
@test readline(p) == "Stacktrace:"
wait(proc)
close(p)
end

0 comments on commit 339911f

Please sign in to comment.