llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[MLIR]`-test-elements-attr-interface` pass crashes in `SparseElementsAttr::getZeroAPInt()` with assertion failure `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"

Open BealZephyr opened this issue 3 years ago • 3 comments

Test commit: https://github.com/llvm/llvm-project/commit/e7281c6f614230860cd18a9d1f24612c5c38e9ca

Steps to reproduce:

mlir-opt test.mlir -test-elements-attr-interface

Test case:

"test.sparse_attr"() {foo.sparse_attr = sparse<[[0, 0, 5]],  -2.0> : vector<1x1x10xf16>} : () -> ()

Crash trace:

mlir-opt: /home/ty/llvm-project/llvm/include/llvm/Support/Casting.h:567: decltype(auto) llvm::cast(const From&) [with To = mlir::IntegerType; From = mlir::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/ty/llvm-project/build/bin/mlir-opt test.mlir -test-elements-attr-interface
 #0 0x000055f0b4a5d60a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/ty/llvm-project/build/bin/mlir-opt+0x22b60a)
 #1 0x000055f0b4a5a89c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f7315be3980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #3 0x00007f7314894e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #4 0x00007f73148967f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
 #5 0x00007f73148863fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
 #6 0x00007f7314886472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
 #7 0x000055f0b649e6f6 mlir::SparseElementsAttr::getZeroAPInt() const (/home/ty/llvm-project/build/bin/mlir-opt+0x1c6c6f6)
 #8 0x000055f0b64a76bc mlir::FailureOr<llvm::mapped_iterator<llvm::detail::SafeIntIterator<long, false>, std::function<llvm::APInt (long)>, decltype(declval<std::function<llvm::APInt (long)>>()(declval<llvm::detail::SafeIntIterator<long, false>>().llvm::detail::SafeIntIterator<long, false>::operator*() const()))>> mlir::SparseElementsAttr::try_value_begin_impl<llvm::APInt>(mlir::detail::ElementsAttrTrait<mlir::SparseElementsAttr>::OverloadToken<llvm::APInt>) const (/home/ty/llvm-project/build/bin/mlir-opt+0x1c756bc)
 #9 0x000055f0b64adfb1 mlir::detail::ElementsAttrInterfaceTraits::Model<mlir::SparseElementsAttr>::getValuesImpl(mlir::detail::ElementsAttrInterfaceTraits::Concept const*, mlir::Attribute, mlir::TypeID) (/home/ty/llvm-project/build/bin/mlir-opt+0x1c7bfb1)
#10 0x000055f0b6483247 mlir::ElementsAttr::getValuesImpl(mlir::TypeID) const (/home/ty/llvm-project/build/bin/mlir-opt+0x1c51247)
#11 0x000055f0b5a86b7e _ZNK4mlir12ElementsAttr15try_value_beginIN4llvm5APIntEEENSt9enable_ifIXoosrSt7is_sameINS_9AttributeET_E5valuentsrSt10is_base_ofIS6_S7_E5valueESt8optionalINS_6detail20ElementsAttrIteratorIS7_EEEE4typeEv (/home/ty/llvm-project/build/bin/mlir-opt+0x1254b7e)
#12 0x000055f0b623abfc void (anonymous namespace)::TestElementsAttrInterface::testElementsAttrIteration<llvm::APInt>(mlir::Operation*, mlir::ElementsAttr, llvm::StringRef) (.isra.175.constprop.186) TestBuiltinAttributeInterfaces.cpp:0:0
#13 0x000055f0b623dde1 void llvm::function_ref<void (mlir::Operation*)>::callback_fn<(anonymous namespace)::TestElementsAttrInterface::runOnOperation()::'lambda'(mlir::Operation*)>(long, mlir::Operation*) TestBuiltinAttributeInterfaces.cpp:0:0
#14 0x000055f0b623d4b5 (anonymous namespace)::TestElementsAttrInterface::runOnOperation() TestBuiltinAttributeInterfaces.cpp:0:0
#15 0x000055f0b637d9be mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b4b9be)
#16 0x000055f0b637e813 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (.constprop.510) Pass.cpp:0:0
#17 0x000055f0b637ee9d mlir::PassManager::run(mlir::Operation*) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b4ce9d)
#18 0x000055f0b6372e13 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#19 0x000055f0b63734e1 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#20 0x000055f0b63736d1 mlir::LogicalResult llvm::function_ref<mlir::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
#21 0x000055f0b64455e0 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/home/ty/llvm-project/build/bin/mlir-opt+0x1c135e0)
#22 0x000055f0b636e7f3 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b3c7f3)
#23 0x000055f0b637101e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b3f01e)
#24 0x000055f0b4a29570 main (/home/ty/llvm-project/build/bin/mlir-opt+0x1f7570)
#25 0x00007f7314877c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#26 0x000055f0b4a3c3da _start (/home/ty/llvm-project/build/bin/mlir-opt+0x20a3da)

BealZephyr avatar Mar 31 '23 12:03 BealZephyr

@llvm/issue-subscribers-mlir

llvmbot avatar Mar 31 '23 14:03 llvmbot

Patch submitted at https://reviews.llvm.org/D151675

sott0n avatar May 30 '23 04:05 sott0n

Patch was not committed yet.

EugeneZelenko avatar Jul 15 '23 05:07 EugeneZelenko