Enzyme and precompilation produces segfault
- Dominant language
- Julia
- Stars
- 586
- Forks
- 108
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 44
Description
The following module is to be put in a package such that it can be precompiled:
```julia
module MyModule
using Enzyme
using SnoopPrecompile
export myfunction, gradient
myfunction(θ) = θ.α^2
gradient(f, θ) = only(autodiff(Reverse, f, Active(θ)))
@precompile_setup begin
θ = (α = 0.1,)
@precompile_all_calls begin
@info gradient(myfunction, θ)
end
end
end
```
In Julia 1.8 and 1.9, the following will trigger a segfault. The segfault does not happen when the precompilation block above is removed.
```julia
julia> using MyModule
[ Info: Precompiling MyModule [e0b44dc7-ccfe-4aa7-a216-f44cae2f5f9d]
[ Info: (α = 0.2,)
julia> θ = (α = 0.1,)
(α = 0.1,)
julia> gradient(myfunction, θ)
signal (11): Segmentation fault
in expression starting at REPL[3]:1
unknown function (ip: 0x7f96c1fd8010)
macro expansion at ~/.julia/packages/Enzyme/DIkTv/src/compiler.jl:6819 [inlined]
enzyme_call at ~/.julia/packages/Enzyme/DIkTv/src/compiler.jl:6544 [inlined]
CombinedAdjointThunk at ~/.julia/packages/Enzyme/DIkTv/src/compiler.jl:6507 [inlined]
autodiff at ~/.julia/packages/Enzyme/DIkTv/src/Enzyme.jl:217 [inlined]
autodiff at ~/.julia/packages/Enzyme/DIkTv/src/Enzyme.jl:248
Allocations: 2762221 (Pool: 2760938; Big: 1283); GC: 3
Segmentation fault (core dumped)
```
Julia 1.8 version info
```julia
julia> versioninfo()
Julia Version 1.8.5
Commit 17cfb8e65ea (2023-01-08 06:45 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
Threads: 1 on 8 virtual cores
```
Julia 1.9 version info
```julia
julia> versioninfo()
Julia Version 1.9.0-rc1
Commit 3b2e0d8fbc1 (2023-03-07 07:51 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
Threads: 1 on 8 virtual cores
```
Contributor guide
Assessment
This issue has not been assessed yet.