llvm / llvm/llvm-project

[mlir][memref](normalize-memrefs) mlir-opt triggers segmentation fault with normalize-memrefs

Open
#205,712 2 comments 0 reactions 0 assignees View on GitHub
crash mlir
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

git version: 6a15e2d75623860436271e52513cc2ca43991e70

MLIR Program:
```mlir
#map = affine_map<(d0, d1, d2) -> (d2, d0, d1)>
module {
llvm.func @m2() {
%0 = func.call @m1() : () -> memref<2x3x5xi32, #map>
llvm.return
}
func.func @m1() -> memref<2x3x5xi32, #map> {
%alloc = memref.alloc() : memref<2x3x5xi32, #map>
return %alloc : memref<2x3x5xi32, #map>
}
}
```

Reproduce Command: `mlir-opt --normalize-memrefs 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 --normalize-memrefs a.mlir
#0 0x00005578775df23f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25cf23f)
#1 0x00005578775db9fc llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25cb9fc)
#2 0x00005578775dbb97 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f5dc6263420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x000055787ebd2c77 mlir::PropertiesSelector::type& mlir::Op::getProperties() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9bc2c77)
#5 0x000055787f5ec80d mlir::func::FuncOp::getFunctionType() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xa5dc80d)
#6 0x000055787e9750ed (anonymous namespace)::NormalizeMemRefs::updateFunctionSignature(mlir::func::FuncOp, mlir::ModuleOp) NormalizeMemRefs.cpp:0:0
#7 0x000055787e975fc2 (anonymous namespace)::NormalizeMemRefs::updateFunctionSignature(mlir::func::FuncOp, mlir::ModuleOp) NormalizeMemRefs.cpp:0:0
#8 0x000055787e977179 (anonymous namespace)::NormalizeMemRefs::normalizeFuncOpMemRefs(mlir::func::FuncOp, mlir::ModuleOp) NormalizeMemRefs.cpp:0:0
#9 0x000055787e9782e7 (anonymous namespace)::NormalizeMemRefs::runOnOperation() NormalizeMemRefs.cpp:0:0
#10 0x000055788041c051 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb40c051)
#11 0x000055788041c3e0 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+0xb40c3e0)
#12 0x000055788041e494 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb40e494)
#13 0x000055788041f521 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb40f521)
#14 0x00005578776a52db performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#15 0x00005578776a5d83 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#16 0x00005578776a600b 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
#17 0x00005578807f5515 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+0xb7e5515)
#18 0x000055787769c114 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#19 0x00005578776a6527 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2696527)
#20 0x00005578776a6763 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2696763)
#21 0x000055787750bb8c main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x24fbb8c)
#22 0x00007f5dc5d2f083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#23 0x00005578775bb92e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25ab92e)
Segmentation fault (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with mlir-opt --normalize-memrefs a.mlir using the MLIR program in the issue. Then inspect NormalizeMemRefs::updateFunctionSignature in NormalizeMemrefs.cpp, where the stack trace points; done means the input no longer triggers a segmentation fault.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.