Skip to content

Commit

Permalink
src/codegen.cpp: fix segfault on @code_native with eltype (#34434) (#…
Browse files Browse the repository at this point in the history
…34458)

(cherry picked from commit 6a96a4d)
  • Loading branch information
anaveragehuman authored and KristofferC committed Feb 5, 2020
1 parent 880b9b1 commit eb75505
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ void *jl_get_llvmf_decl(jl_method_instance_t *mi, size_t world, bool getwrapper,
// internal error
return NULL;

const jl_llvm_functions_t &decls = codeinst->functionObjectsDecls;
jl_llvm_functions_t decls = codeinst->functionObjectsDecls;
if (decls.functionObject == NULL && codeinst->invoke == jl_fptr_const_return && jl_is_method(mi->def.method)) {
// normally we don't generate native code for these functions, so need an exception here
// This leaks a bit of memory to cache native code that we'll never actually need
Expand All @@ -1699,6 +1699,7 @@ void *jl_get_llvmf_decl(jl_method_instance_t *mi, size_t world, bool getwrapper,
if (codeinst == NULL)
// internal error
return NULL;
decls = codeinst->functionObjectsDecls;
}
JL_UNLOCK(&codegen_lock);
}
Expand Down
6 changes: 6 additions & 0 deletions stdlib/InteractiveUtils/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,9 @@ end
# buildbot path updating
file, ln = functionloc(versioninfo, Tuple{})
@test isfile(file)

@testset "Issue #34434" begin
io = IOBuffer()
code_native(io, eltype, Tuple{Int})
@test occursin("eltype", String(take!(io)))
end

0 comments on commit eb75505

Please sign in to comment.