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
  • Loading branch information
anaveragehuman authored and KristofferC committed Apr 11, 2020
1 parent 69736b0 commit ecb2e89
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 @@ -1684,7 +1684,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 @@ -1698,6 +1698,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 @@ -446,3 +446,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 ecb2e89

Please sign in to comment.