Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Metal: bus error in the LLVM inliner on dynamic code, instead of an InvalidIRError

Aperta
#965 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
28/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
julia
Ambito
compilers

Direzione di ricerca

Reproduce the kernel with GPUCompiler main on the stated Julia and M1 setup, comparing optimized compilation with Metal.code_llvm(...; optimize = false). Start at GPUCompiler/src/metal.jl:425 and follow the optimize! and emit_llvm paths, using the LLVM inliner and InvalidIRError behavior as reference points. Done means the dynamic llvmcall case no longer crashes during optimization and reports an InvalidIRError instead.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

metal

Compiling a Metal kernel that ends up with dynamic code crashes the process during optimization, instead of reporting an InvalidIRError:

using Metal, UnsafeAtomics   # UnsafeAtomics from JuliaConcurrent/UnsafeAtomics.jl#30
const UA = UnsafeAtomics
wrapper(p, x; kwargs...) = UA.add!(p, x, UA.monotonic, UA.device; kwargs...)
k(a) = (wrapper(pointer(a), Int32(1); volatile = true, align = 8); nothing)
@metal threads=1 k(MtlArray(Int32[0]))
[30093] signal 10 (1): Bus error: 10
_ZN12_GLOBAL__N_112CallAnalyzer7analyzeEv at .../libLLVM.dylib
llvm::getInlineCost(...)
...
llvm::InlinerPass::run(...)
...
llvm::ModuleInlinerWrapperPass::run(...)
LLVMRunJuliaPasses at LLVM/JGisQ/lib/18/libLLVM_extra.jl:319
run! at LLVM/JGisQ/src/newpm.jl:380
optimize_module! at GPUCompiler/src/metal.jl:425
optimize! at GPUCompiler/src/optim.jl:52
emit_llvm at GPUCompiler/src/driver.jl:176

GPUCompiler main (037ef5a), Julia 1.12.7, M1. The same crash happens with the Metal atomics branch (#942/#943). With #949, it crashed earlier instead, in check_allocation!/referenced_object.

The code is dynamic because Julia doesn't const-prop the keywords into the non-inlined wrapper, so align is a run-time value and Val(align) becomes a dynamic call to UnsafeAtomics' @generated llvmcall primitive. Base.@constprop :aggressive on the wrapper avoids it. Metal.code_llvm(…; optimize = false) works and gives about 2,400 lines of IR (typejoin, _growbeg!, boxing, …); the crash is in the LLVM inliner over that module. A similar kernel whose dynamic code doesn't involve llvmcall (wrapper(a, x; kwargs...) = store(a, x, Val(kwargs[:index]))) is correctly reported as an InvalidIRError.

Lingua principale
Julia
Stelle
188
Fork
71
Merge medio
1g 12h
PR unite (30g)
72

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di JuliaGPU/GPUCompiler.jl

Tutte le issue di JuliaGPU/GPUCompiler.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.