[mlir] mlir-opt triggers segmentation fault with optimize-allocation-liveness
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
git version: b7c56b5b0a54a6c966a74dfe311fcddcffade521
MLIR Program:
```mlir
module {
func.func @m(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
cf.cond_br %arg0, ^bb1, ^bb2
^bb1: // pred: ^bb0
cf.br ^bb3(%arg1 : memref<2xf32>)
^bb2: // pred: ^bb0
%alloc = memref.alloc() : memref<2xf32>
test.buffer_based in(%arg1 : memref<2xf32>) out(%alloc : memref<2xf32>)
memref.dealloc %alloc : memref<2xf32>
cf.br ^bb3(%alloc : memref<2xf32>)
^bb3(%0: memref<2xf32>): // 2 preds: ^bb1, ^bb2
test.copy(%0, %arg2) : (memref<2xf32>, memref<2xf32>)
return
}
}
```
Reproduce Command: `mlir-opt -optimize-allocation-liveness a.mlir`
StackTrace:
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /data2/dependency/dev/llvm-project/build/bin/mlir-opt -optimize-allocation-liveness a.mlir
#0 0x000055e05bbab1df llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25e71df)
#1 0x000055e05bba799c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25e399c)
#2 0x000055e05bba7b37 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f1cfa386420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x000055e064dab4eb mlir::Operation::isProperAncestor(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb7e74eb)
#5 0x000055e0630e955b (anonymous namespace)::OptimizeAllocationLiveness::runOnOperation()::'lambda'(mlir::MemoryEffectOpInterface)::operator()(mlir::MemoryEffectOpInterface) const (.isra.0) OptimizeAllocationLiveness.cpp:0:0
#6 0x000055e0630e9f1c _ZN4llvm12function_refIFN4mlir10WalkResultEPNS1_9OperationEEE11callback_fnIZNS1_6detail4walkILNS1_9WalkOrderE1ENS1_15ForwardIteratorEZN12_GLOBAL__N_126OptimizeAllocationLiveness14runOnOperationEvEUlNS1_23MemoryEffectOpInterfaceEE_SE_S2_EENSt9enable_ifIXaantsrSt11disjunctionIJSt7is_sameIT2_S4_ESI_ISJ_PNS1_6RegionEESI_ISJ_PNS1_5BlockEEEE5valuesrSI_IT3_S2_E5valueESS_E4typeES4_OT1_EUlS4_E_EES2_lS4_ OptimizeAllocationLiveness.cpp:0:0
#7 0x000055e0630ea5fd (anonymous namespace)::OptimizeAllocationLiveness::runOnOperation() OptimizeAllocationLiveness.cpp:0:0
#8 0x000055e064a335b1 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb46f5b1)
#9 0x000055e064a33940 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb46f940)
#10 0x000055e064a3421e mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda12'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#11 0x000055e064a32560 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb46e560)
#12 0x000055e064a3348b mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb46f48b)
#13 0x000055e064a33940 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb46f940)
#14 0x000055e064a359f4 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb4719f4)
#15 0x000055e064a36a81 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb472a81)
#16 0x000055e05bc7127b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#17 0x000055e05bc71d23 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#18 0x000055e05bc71fab llvm::LogicalResult llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr>, llvm::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#19 0x000055e064e0ca75 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb848a75)
#20 0x000055e05bc680b4 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#21 0x000055e05bc724c7 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x26ae4c7)
#22 0x000055e05bc72703 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x26ae703)
#23 0x000055e05bad7b2c main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2513b2c)
#24 0x00007f1cf9e52083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#25 0x000055e05bb878ce _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25c38ce)
Segmentation fault (core dumped)
```
Contributor guide
Research direction
Reproduce the crash with `mlir-opt -optimize-allocation-liveness a.mlir` using the MLIR program in the report. Start at `OptimizeAllocationLiveness::runOnOperation()` in `OptimizeAllocationLiveness.cpp` and inspect the `Operation::isProperAncestor` stack frame; done means this input completes without a segmentation fault.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100