llvm / llvm/llvm-project

[mlir] mlir-opt triggers segmentation fault with sparsification=sparse-emit-strategy=sparse-iterator

Open
#205,706 1 comment 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) -> (d0, d1)>
#sparse = #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : compressed, d1 : compressed) }>
module {
func.func @m0(%arg0: tensor<4x4xf32>) -> tensor<4x4xf32, #sparse> {
%0 = tensor.empty() : tensor<4x4xf32, #sparse>
%1 = linalg.generic {indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel"]} ins(%arg0 : tensor<4x4xf32>) outs(%0 : tensor<4x4xf32, #sparse>) attrs = {sorted = true} {
^bb0(%in: f32, %out: f32):
linalg.yield %in : f32
} -> tensor<4x4xf32, #sparse>
return %1 : tensor<4x4xf32, #sparse>
}
}
```

Reproduce Command: `mlir-opt -sparsification=sparse-emit-strategy=sparse-iterator 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 -sparsification=sparse-emit-strategy=sparse-iterator a.mlir
#0 0x000056529ce1123f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25cf23f)
#1 0x000056529ce0d9fc llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25cb9fc)
#2 0x000056529ce0db97 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007ffaa0950420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00005652a43bda17 mlir::sparse_tensor::SparseTensorEncodingAttr::print(mlir::AsmPrinter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9b7ba17)
#5 0x00005652a43bdc6c void mlir::AsmPrinter::printStrippedAttrOrType(mlir::sparse_tensor::SparseTensorEncodingAttr) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9b7bc6c)
#6 0x00005652a43bdd04 mlir::sparse_tensor::IterSpaceType::print(mlir::AsmPrinter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9b7bd04)
#7 0x00005652a43bdfec mlir::sparse_tensor::SparseTensorDialect::printType(mlir::Type, mlir::DialectAsmPrinter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9b7bfec)
#8 0x00005652a5ed31c4 mlir::AsmPrinter::Impl::printDialectType(mlir::Type) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb6911c4)
#9 0x00005652a5ee85f6 mlir::AsmPrinter::Impl::printTypeImpl(mlir::Type) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb6a65f6)
#10 0x00005652a5ed19af mlir::OpAsmPrinter::printFunctionalType(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb68f9af)
#11 0x00005652a5eebd75 (anonymous namespace)::OperationPrinter::printGenericOp(mlir::Operation*, bool) AsmPrinter.cpp:0:0
#12 0x00005652a5eec2fa (anonymous namespace)::OperationPrinter::printCustomOrGenericOp(mlir::Operation*) AsmPrinter.cpp:0:0
#13 0x00005652a5eec8c5 (anonymous namespace)::OperationPrinter::printFullOpWithIndentAndLoc(mlir::Operation*) AsmPrinter.cpp:0:0
#14 0x00005652a5eedc00 mlir::Operation::print(llvm::raw_ostream&, mlir::AsmState&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb6abc00)
#15 0x00005652a5ef02d7 mlir::Operation::print(llvm::raw_ostream&, mlir::OpPrintingFlags const&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb6ae2d7)
#16 0x00005652a5f6fe50 mlir::Diagnostic::appendOp(mlir::Operation&, mlir::OpPrintingFlags const&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb72de50)
#17 0x00005652a5fc9378 mlir::Operation::emitError(llvm::Twine const&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb787378)
#18 0x00005652a5fc998d mlir::Operation::emitOpError(llvm::Twine const&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb78798d)
#19 0x00005652a43d204a __mlir_ods_local_type_constraint_SparseTensorOps1(mlir::Operation*, mlir::Type, llvm::StringRef, unsigned int) SparseTensorDialect.cpp:0:0
#20 0x00005652a43dd66b mlir::sparse_tensor::ExtractIterSpaceOp::verifyInvariantsImpl() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9b9b66b)
#21 0x00005652a43e9b18 mlir::Op::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::AtLeastNOperands<1u>::Impl, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::InferTypeOpInterface::Trait>::verifyInvariants(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9ba7b18)
#22 0x00005652a43f5738 mlir::RegisteredOperationName::Model::verifyInvariants(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9bb3738)
#23 0x00005652a600cb74 (anonymous namespace)::OperationVerifier::verifyOnEntrance(mlir::Operation&) Verifier.cpp:0:0
#24 0x00005652a600ee70 (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#25 0x00005652a600f80f (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#26 0x00005652a60107cf mlir::verify(mlir::Operation*, bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb7ce7cf)
#27 0x00005652a5c4e078 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb40c078)
#28 0x00005652a5c4e3e0 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)
#29 0x00005652a5c50494 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb40e494)
#30 0x00005652a5c51521 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb40f521)
#31 0x000056529ced72db performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#32 0x000056529ced7d83 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#33 0x000056529ced800b 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
#34 0x00005652a6027515 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)
#35 0x000056529cece114 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#36 0x000056529ced8527 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2696527)
#37 0x000056529ced8763 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2696763)
#38 0x000056529cd3db8c main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x24fbb8c)
#39 0x00007ffaa041c083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#40 0x000056529cded92e _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 using the supplied MLIR input and sparsification option. Inspect SparseTensorDialect.cpp, especially SparseTensorEncodingAttr::print and ExtractIterSpaceOp verification, then add a regression test covering this input. Done means mlir-opt reports a diagnostic or completes without a segmentation fault.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.