JuliaLang/julia
Ver no GitHub`llvmcall` segfaults if an argument has size 0
Open
#60.063 aberto em 6 de nov. de 2025
compiler:codegencompiler:llvmgood first issue
Métricas do repositório
- Stars
- (48.709 stars)
- Métricas de merge de PR
- (Mesclagem média 23d 11h) (145 fundiu PRs em 30d)
Description
llvmcall catches incorrect argument types, but it doesn't catch arguments with empty bit representation (which are presumably not allowed in LLVM IR). I think it would be better if llvmcall threw an error in this case.
julia> f(x::T) where T = Base.llvmcall("ret i8 %0", Int8, Tuple{T}, x);
julia> f(1)
ERROR: Failed to parse LLVM assembly:
<string>:2:8: error: '%0' defined with type 'i64' but expected 'i8'
ret i8 %0
^
julia> f(nothing)
[26746] signal 11 (1): Segmentation fault
in expression starting at REPL[3]:1
llvm_type_rewrite at /cache/build/tester-amdci4-14/julialang/julia-release-1-dot-12/src/ccall.cpp:407
emit_llvmcall at /cache/build/tester-amdci4-14/julialang/julia-release-1-dot-12/src/ccall.cpp:826
emit_intrinsic at /cache/build/tester-amdci4-14/julialang/julia-release-1-dot-12/src/intrinsics.cpp:1307
emit_call at /cache/build/tester-amdci4-14/julialang/julia-release-1-dot-12/src/codegen.cpp:5456
emit_expr at /cache/build/tester-amdci4-14/julialang/julia-release-1-dot-12/src/codegen.cpp:6383
emit_ssaval_assign at /cache/build/tester-amdci4-14/julialang/julia-release-1-dot-12/src/codegen.cpp:5870
emit_stmtpos at /cache/build/tester-amdci4-14/julialang/julia-release-1-dot-12/src/codegen.cpp:6172 [inlined]
emit_function at /cache/build/tester-amdci4-14/julialang/julia-release-1-dot-12/src/codegen.cpp:9347
[...]
Tested with Julia 1.12. Same with a few days old 1.13-nightly.
julia> versioninfo()
Julia Version 1.12.1
Commit ba1e628ee49 (2025-10-17 13:02 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 4 × Intel(R) Core(TM) i3-10110U CPU @ 2.10GHz
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, skylake)
GC: Built with stock GC