Issue 131323
Summary [MLIR] crash when initializing complex tensor using dense<scalar>
Labels mlir
Assignees
Reporter zitongzhoueric
    To reproduce: https://godbolt.org/z/EKeYbMnab

The program causing the crash:
```
func.func @test_constant_complex_tensor_with_scalar_initialization() -> () {
    %0 = arith.constant dense<1> : tensor<complex<i32>>
    return
}
``` 
It appears that the use of `dense<1>` for initializing a complex tensor triggered the segfault. The type mismatch should be checked and invalidated.

Stack dump
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/mlir-trunk/bin/mlir-opt -o /app/example.out.mlir <source>
 #0 0x00000000018efff8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x18efff8)
 #1 0x00000000018ed934 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007145a4042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007145a41a7ca5 (/lib/x86_64-linux-gnu/libc.so.6+0x1a7ca5)
 #4 0x00000000041b6f15 mlir::DenseElementsAttr::ComplexIntElementIterator::operator*() const (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x41b6f15)
 #5 0x000000000417c8d1 void llvm::function_ref<void (unsigned int)>::callback_fn<mlir::AsmPrinter::Impl::printDenseIntOrFPElementsAttr(mlir::DenseIntOrFPElementsAttr, bool)::'lambda'(unsigned int)>(long, unsigned int) AsmPrinter.cpp:0:0
 #6 0x000000000417f307 printDenseElementsAttrImpl(bool, mlir::ShapedType, llvm::raw_ostream&, llvm::function_ref<void (unsigned int)>) AsmPrinter.cpp:0:0
 #7 0x000000000418abee mlir::AsmPrinter::Impl::printDenseIntOrFPElementsAttr(mlir::DenseIntOrFPElementsAttr, bool) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x418abee)
 #8 0x0000000004193cb9 mlir::AsmPrinter::Impl::printAttributeImpl(mlir::Attribute, mlir::AsmPrinter::Impl::AttrTypeElision) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x4193cb9)
 #9 0x0000000001afcbb7 mlir::arith::ConstantOp::print(mlir::OpAsmPrinter&) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x1afcbb7)
#10 0x0000000001b7430f void llvm::detail::UniqueFunctionBase<void, mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef>::CallImpl<mlir::Op<mlir::arith::ConstantOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::Type>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::ZeroOperands, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::OpTrait::ConstantLike, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::OpAsmOpInterface::Trait, mlir::InferIntRangeInterface::Trait, mlir::InferTypeOpInterface::Trait>::getPrintAssemblyFn()::'lambda'(mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) const>(void*, mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x1b7430f)
#11 0x0000000001b97d50 mlir::RegisteredOperationName::Model<mlir::arith::ConstantOp>::printAssembly(mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x1b97d50)
#12 0x0000000004197c8a (anonymous namespace)::OperationPrinter::printCustomOrGenericOp(mlir::Operation*) AsmPrinter.cpp:0:0
#13 0x00000000041981b5 (anonymous namespace)::OperationPrinter::printFullOpWithIndentAndLoc(mlir::Operation*) AsmPrinter.cpp:0:0
#14 0x0000000004198833 (anonymous namespace)::OperationPrinter::print(mlir::Block*, bool, bool) AsmPrinter.cpp:0:0
#15 0x0000000004198f19 (anonymous namespace)::OperationPrinter::printRegion(mlir::Region&, bool, bool, bool) (.part.0) AsmPrinter.cpp:0:0
#16 0x00000000076e00bf mlir::function_interface_impl::printFunctionOp(mlir::OpAsmPrinter&, mlir::FunctionOpInterface, bool, llvm::StringRef, mlir::StringAttr, mlir::StringAttr) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x76e00bf)
#17 0x0000000001f0924e void llvm::detail::UniqueFunctionBase<void, mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef>::CallImpl<mlir::Op<mlir::func::FuncOp, mlir::OpTrait::OneRegion, mlir::OpTrait::ZeroResults, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::ZeroOperands, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::OpTrait::AffineScope, mlir::OpTrait::AutomaticAllocationScope, mlir::SymbolOpInterface::Trait, mlir::CallableOpInterface::Trait, mlir::FunctionOpInterface::Trait, mlir::OpTrait::IsIsolatedFromAbove, mlir::OpAsmOpInterface::Trait>::getPrintAssemblyFn()::'lambda'(mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) const>(void*, mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x1f0924e)
#18 0x0000000001efdd71 mlir::RegisteredOperationName::Model<mlir::func::FuncOp>::printAssembly(mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x1efdd71)
#19 0x0000000004197c8a (anonymous namespace)::OperationPrinter::printCustomOrGenericOp(mlir::Operation*) AsmPrinter.cpp:0:0
#20 0x00000000041981b5 (anonymous namespace)::OperationPrinter::printFullOpWithIndentAndLoc(mlir::Operation*) AsmPrinter.cpp:0:0
#21 0x0000000004198833 (anonymous namespace)::OperationPrinter::print(mlir::Block*, bool, bool) AsmPrinter.cpp:0:0
#22 0x0000000004198f19 (anonymous namespace)::OperationPrinter::printRegion(mlir::Region&, bool, bool, bool) (.part.0) AsmPrinter.cpp:0:0
#23 0x00000000041e3ddb mlir::ModuleOp::print(mlir::OpAsmPrinter&) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x41e3ddb)
#24 0x00000000041e3e4f void llvm::detail::UniqueFunctionBase<void, mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef>::CallImpl<mlir::Op<mlir::ModuleOp, mlir::OpTrait::OneRegion, mlir::OpTrait::ZeroResults, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::ZeroOperands, mlir::OpTrait::NoRegionArguments, mlir::OpTrait::NoTerminator, mlir::OpTrait::SingleBlock, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::OpTrait::AffineScope, mlir::OpTrait::IsIsolatedFromAbove, mlir::OpTrait::SymbolTable, mlir::SymbolOpInterface::Trait, mlir::OpAsmOpInterface::Trait, mlir::RegionKindInterface::Trait, mlir::OpTrait::HasOnlyGraphRegion>::getPrintAssemblyFn()::'lambda'(mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) const>(void*, mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x41e3e4f)
#25 0x00000000041de221 mlir::RegisteredOperationName::Model<mlir::ModuleOp>::printAssembly(mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x41de221)
#26 0x0000000004197c8a (anonymous namespace)::OperationPrinter::printCustomOrGenericOp(mlir::Operation*) AsmPrinter.cpp:0:0
#27 0x00000000041981b5 (anonymous namespace)::OperationPrinter::printFullOpWithIndentAndLoc(mlir::Operation*) AsmPrinter.cpp:0:0
#28 0x000000000419d406 mlir::Operation::print(llvm::raw_ostream&, mlir::AsmState&) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x419d406)
#29 0x00000000040695ef performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#30 0x0000000004069ccb processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#31 0x0000000004069df3 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#32 0x000000000416832e mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x416832e)
#33 0x0000000004062115 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x4062115)
#34 0x0000000004069f20 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x4069f20)
#35 0x000000000406a3af mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x406a3af)
#36 0x000000000180064f main (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x180064f)
#37 0x00007145a4029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#38 0x00007145a4029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#39 0x00000000018ca5d5 _start (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x18ca5d5)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to