Caching potentially causes intermittent segfault
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 26
Description
I was seeing intermittent segfaults in this line
https://github.com/EnzymeAD/Enzyme/blob/ad6c5f6610bdc85ce91718106ccc34706a7ca382/enzyme/Enzyme/MLIR/Passes/EnzymeMLIRPass.cpp#L342
The segfaults stopped if I deleted this cache fetch
https://github.com/EnzymeAD/Enzyme/blob/9b78a1cdfbb36edd57ff8d879fc8d29beb6e0eee/enzyme/Enzyme/MLIR/Interfaces/EnzymeLogicReverse.cpp#L219-L223
This was observed when differentiating several MLIR graphs, such as below. Each graph would be run anywhere between 2 to 400 times, each run with different constants. I ran it using the C++ API, not command line.
```
module @root {
func.func @main() -> tensor {
%cst = stablehlo.constant dense<1.000000e+00> : tensor
%cst_0 = stablehlo.constant dense<0.000000e+00> : tensor
%0 = enzyme.autodiff_region(%cst_0, %cst) {
^bb0(%arg0: tensor):
enzyme.yield %arg0 : tensor
} attributes {activity = [#enzyme], ret_activity = [#enzyme]} : (tensor, tensor) -> tensor
return %0 : tensor
}
}
```
These are my passes
```
{-#
external_resources: {
mlir_reproducer: {
pipeline: "builtin.module(outline-enzyme-regions, enzyme{postpasses=canonicalize,remove-unnecessary-enzyme-ops verifyPostPasses=true}, arith-raise{stablehlo=true})",
disable_threading: false,
verify_each: true
}
}
#-}
```
Contributor guide
Assessment
This issue has not been assessed yet.