Skip to content

Commit eb75505

Browse files
anaveragehumanKristofferC
authored andcommitted
src/codegen.cpp: fix segfault on @code_native with eltype (#34434) (#34458)
(cherry picked from commit 6a96a4d)
1 parent 880b9b1 commit eb75505

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/codegen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ void *jl_get_llvmf_decl(jl_method_instance_t *mi, size_t world, bool getwrapper,
16851685
// internal error
16861686
return NULL;
16871687

1688-
const jl_llvm_functions_t &decls = codeinst->functionObjectsDecls;
1688+
jl_llvm_functions_t decls = codeinst->functionObjectsDecls;
16891689
if (decls.functionObject == NULL && codeinst->invoke == jl_fptr_const_return && jl_is_method(mi->def.method)) {
16901690
// normally we don't generate native code for these functions, so need an exception here
16911691
// This leaks a bit of memory to cache native code that we'll never actually need
@@ -1699,6 +1699,7 @@ void *jl_get_llvmf_decl(jl_method_instance_t *mi, size_t world, bool getwrapper,
16991699
if (codeinst == NULL)
17001700
// internal error
17011701
return NULL;
1702+
decls = codeinst->functionObjectsDecls;
17021703
}
17031704
JL_UNLOCK(&codegen_lock);
17041705
}

stdlib/InteractiveUtils/test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,9 @@ end
433433
# buildbot path updating
434434
file, ln = functionloc(versioninfo, Tuple{})
435435
@test isfile(file)
436+
437+
@testset "Issue #34434" begin
438+
io = IOBuffer()
439+
code_native(io, eltype, Tuple{Int})
440+
@test occursin("eltype", String(take!(io)))
441+
end

0 commit comments

Comments
 (0)