Skip to content

Assertion failure in DenseArrayAttr parser #9374

@sairam2661

Description

@sairam2661

Test commit
417a5112947d9889cad54cb5b2110b37978b86b8

Description
The MLIR parser crashes when a DenseArrayAttr uses i1 as its element type. The parser expects the bitwidth of the array data to be a multiple of 8, which gets violated by this.

Steps to reproduce

  • Minimal MLIR program (test.mlir)
"builtin.module"() ({
  "func.func"() <{function_type = (i32) -> i32, sym_name = "dot"}> ({
  ^bb0(%arg0: i32):
    %0 = "affine.for"(%arg0) <{
      lowerBoundMap = affine_map<() -> (0)>,
      operandSegmentSizes = array<i1: 0, 0, 1>,
      step = 1 : index,
      upperBoundMap = affine_map<() -> (64)>
    }> ({
    ^bb0(%arg1: index, %arg2: i32):
      "affine.yield"(%arg2) : (i32) -> ()
    }) : (i32) -> i32
    "func.return"(%0) : (i32) -> i32
  }) : () -> ()
}) : () -> ()

Command

circt-opt test.mlir

Output

circt-opt: /workdir/sources/circt/llvm/mlir/lib/AsmParser/AttributeParser.cpp:863: void (anonymous namespace)::DenseArrayElementParser::append(const llvm::APInt &): Assertion `data.getBitWidth() % 8 == 0' failed.
PLEASE submit a bug report to https://github.com/llvm/circt and include the crash backtrace.
Stack dump:
0.      Program arguments: /workdir/builds/circt/bin/circt-opt test.mlir
 #0 0x000055c34804f94b backtrace (/workdir/builds/circt/bin/circt-opt+0x6f4e94b)
 #1 0x000055c3481df747 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /workdir/sources/circt/llvm/llvm/lib/Support/Unix/Signals.inc:834:13
 #2 0x000055c3481dd373 llvm::sys::RunSignalHandlers() /workdir/sources/circt/llvm/llvm/lib/Support/Signals.cpp:105:18
 #3 0x000055c3481e04b5 SignalHandler(int, siginfo_t*, void*) /workdir/sources/circt/llvm/llvm/lib/Support/Unix/Signals.inc:426:38
 #4 0x00007f98afecf520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x00007f98aff239fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #6 0x00007f98afecf476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #7 0x00007f98afeb57f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #8 0x00007f98afeb571b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #9 0x00007f98afec6e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x000055c34ebe09d4 (/workdir/builds/circt/bin/circt-opt+0xdadf9d4)
#11 0x000055c34ebe6341 llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#12 0x000055c34ebe6341 llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#13 0x000055c34ebe6341 mlir::detail::Parser::parseCommaSeparatedList(mlir::AsmParser::Delimiter, llvm::function_ref<llvm::ParseResult ()>, llvm::StringRef) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:138:7
#14 0x000055c34ebdb8a1 mlir::detail::Parser::parseDenseArrayAttr(mlir::Type) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.h:0:12
#15 0x000055c34ebe046f mlir::Attribute::operator!() const /workdir/sources/circt/llvm/mlir/include/mlir/IR/Attributes.h:48:40
#16 0x000055c34ebe046f mlir::detail::Parser::parseAttributeDict(mlir::NamedAttrList&)::$_1::operator()() const /workdir/sources/circt/llvm/mlir/lib/AsmParser/AttributeParser.cpp:329:9
#17 0x000055c34ebe046f llvm::ParseResult llvm::function_ref<llvm::ParseResult ()>::callback_fn<mlir::detail::Parser::parseAttributeDict(mlir::NamedAttrList&)::$_1>(long) /workdir/sources/circt/llvm/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#18 0x000055c34ebe6398 llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#19 0x000055c34ebe6398 llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#20 0x000055c34ebe6398 mlir::detail::Parser::parseCommaSeparatedList(mlir::AsmParser::Delimiter, llvm::function_ref<llvm::ParseResult ()>, llvm::StringRef) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:143:9
#21 0x000055c34ebdb9c2 mlir::detail::Parser::parseAttributeDict(mlir::NamedAttrList&) /workdir/sources/circt/llvm/mlir/lib/AsmParser/AttributeParser.cpp:335:10
#22 0x000055c34ebda81e llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#23 0x000055c34ebda81e llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#24 0x000055c34ebda81e mlir::detail::Parser::parseAttribute(mlir::Type) /workdir/sources/circt/llvm/mlir/lib/AsmParser/AttributeParser.cpp:109:9
#25 0x000055c34ebf1c88 (anonymous namespace)::OperationParser::parseGenericOperationAfterOpName(mlir::OperationState&, std::optional<llvm::ArrayRef<mlir::OpAsmParser::UnresolvedOperand> >, std::optional<llvm::ArrayRef<mlir::Block*> >, std::optional<llvm::MutableArrayRef<std::unique_ptr<mlir::Region, std::default_delete<mlir::Region> > > >, std::optional<llvm::ArrayRef<mlir::NamedAttribute> >, std::optional<mlir::Attribute>, std::optional<mlir::FunctionType>) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:1418:27
#26 0x000055c34ebece35 llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#27 0x000055c34ebece35 llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#28 0x000055c34ebece35 (anonymous namespace)::OperationParser::parseGenericOperation() /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:1527:7
#29 0x000055c34ebe9c9d (anonymous namespace)::OperationParser::parseOperation() /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:0:10
#30 0x000055c34ebf4989 llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#31 0x000055c34ebf4989 llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#32 0x000055c34ebf4989 (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:2440:9
#33 0x000055c34ebf4989 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:2425:21
#34 0x000055c34ebf26e0 llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#35 0x000055c34ebf26e0 llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#36 0x000055c34ebf26e0 (anonymous namespace)::OperationParser::parseRegionBody(mlir::Region&, llvm::SMLoc, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:2328:7
#37 0x000055c34ebf26e0 (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:2257:7
#38 0x000055c34ebf1dad llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#39 0x000055c34ebf1dad llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#40 0x000055c34ebf1dad (anonymous namespace)::OperationParser::parseGenericOperationAfterOpName(mlir::OperationState&, std::optional<llvm::ArrayRef<mlir::OpAsmParser::UnresolvedOperand> >, std::optional<llvm::ArrayRef<mlir::Block*> >, std::optional<llvm::MutableArrayRef<std::unique_ptr<mlir::Region, std::default_delete<mlir::Region> > > >, std::optional<llvm::ArrayRef<mlir::NamedAttribute> >, std::optional<mlir::Attribute>, std::optional<mlir::FunctionType>) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:1430:13
#41 0x000055c34ebece35 llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#42 0x000055c34ebece35 llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#43 0x000055c34ebece35 (anonymous namespace)::OperationParser::parseGenericOperation() /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:1527:7
#44 0x000055c34ebe9c9d (anonymous namespace)::OperationParser::parseOperation() /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:0:10
#45 0x000055c34ebf4840 llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#46 0x000055c34ebf4840 llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#47 0x000055c34ebf4840 (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:2440:9
#48 0x000055c34ebf4840 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:2370:12
#49 0x000055c34ebf26e0 llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#50 0x000055c34ebf26e0 llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#51 0x000055c34ebf26e0 (anonymous namespace)::OperationParser::parseRegionBody(mlir::Region&, llvm::SMLoc, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:2328:7
#52 0x000055c34ebf26e0 (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:2257:7
#53 0x000055c34ebf1dad llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#54 0x000055c34ebf1dad llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#55 0x000055c34ebf1dad (anonymous namespace)::OperationParser::parseGenericOperationAfterOpName(mlir::OperationState&, std::optional<llvm::ArrayRef<mlir::OpAsmParser::UnresolvedOperand> >, std::optional<llvm::ArrayRef<mlir::Block*> >, std::optional<llvm::MutableArrayRef<std::unique_ptr<mlir::Region, std::default_delete<mlir::Region> > > >, std::optional<llvm::ArrayRef<mlir::NamedAttribute> >, std::optional<mlir::Attribute>, std::optional<mlir::FunctionType>) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:1430:13
#56 0x000055c34ebece35 llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#57 0x000055c34ebece35 llvm::ParseResult::operator bool() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:124:53
#58 0x000055c34ebece35 (anonymous namespace)::OperationParser::parseGenericOperation() /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:1527:7
#59 0x000055c34ebe9c9d (anonymous namespace)::OperationParser::parseOperation() /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:0:10
#60 0x000055c34ebe8acd (anonymous namespace)::TopLevelOperationParser::parse(mlir::Block*, mlir::Location) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:0:20
#61 0x000055c34ebe8acd mlir::parseAsmSourceFile(llvm::SourceMgr const&, mlir::Block*, mlir::ParserConfig const&, mlir::AsmParserState*, mlir::AsmParserCodeCompleteContext*) /workdir/sources/circt/llvm/mlir/lib/AsmParser/Parser.cpp:2930:41
#62 0x000055c34e630fbf mlir::parseSourceFile(std::shared_ptr<llvm::SourceMgr> const&, mlir::Block*, mlir::ParserConfig const&, mlir::LocationAttr*) /workdir/sources/circt/llvm/mlir/lib/Parser/Parser.cpp:65:1
#63 0x000055c34e62fa4e llvm::LogicalResult::failed() const /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#64 0x000055c34e62fa4e llvm::failed(llvm::LogicalResult) /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:71:58
#65 0x000055c34e62fa4e mlir::OwningOpRef<mlir::ModuleOp> mlir::detail::parseSourceFile<mlir::ModuleOp, std::shared_ptr<llvm::SourceMgr> const&>(mlir::ParserConfig const&, std::shared_ptr<llvm::SourceMgr> const&) /workdir/sources/circt/llvm/mlir/include/mlir/Parser/Parser.h:158:7
#66 0x000055c34e62fa4e mlir::OwningOpRef<mlir::ModuleOp> mlir::parseSourceFile<mlir::ModuleOp>(std::shared_ptr<llvm::SourceMgr> const&, mlir::ParserConfig const&) /workdir/sources/circt/llvm/mlir/include/mlir/Parser/Parser.h:188:10
#67 0x000055c34e62fa4e mlir::parseSourceFileForTool(std::shared_ptr<llvm::SourceMgr> const&, mlir::ParserConfig const&, bool) /workdir/sources/circt/llvm/mlir/include/mlir/Tools/ParseUtilities.h:31:12
#68 0x000055c34e62e73b mlir::Timer::stop() /workdir/sources/circt/llvm/mlir/include/mlir/Support/Timing.h:218:9
#69 0x000055c34e62e73b mlir::TimingScope::stop() /workdir/sources/circt/llvm/mlir/include/mlir/Support/Timing.h:301:11
#70 0x000055c34e62e73b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /workdir/sources/circt/llvm/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:523:16
#71 0x000055c34e62e4ae processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) /workdir/sources/circt/llvm/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:673:12
#72 0x000055c34e62e4ae mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_3::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::MemoryBufferRef, llvm::raw_ostream&) const /workdir/sources/circt/llvm/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:771:12
#73 0x000055c34e62e4ae llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::MemoryBufferRef const&, 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&)::$_3>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::MemoryBufferRef const&, llvm::raw_ostream&) /workdir/sources/circt/llvm/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#74 0x000055c34e65777b llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::MemoryBufferRef const&, llvm::raw_ostream&) const /workdir/sources/circt/llvm/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:12
#75 0x000055c34e65777b 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::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) /workdir/sources/circt/llvm/mlir/lib/Support/ToolUtilities.cpp:30:12
#76 0x000055c34e625d52 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /workdir/sources/circt/llvm/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:776:26
#77 0x000055c34e626089 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /workdir/sources/circt/llvm/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:822:14
#78 0x000055c34e6262cd mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /workdir/sources/circt/llvm/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:838:10
#79 0x000055c3480d55f3 llvm::failed(llvm::LogicalResult) /workdir/sources/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:71:42
#80 0x000055c3480d55f3 main /workdir/sources/circt/tools/circt-opt/circt-opt.cpp:86:10
#81 0x00007f98afeb6d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#82 0x00007f98afeb6e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#83 0x000055c348013e15 _start (/workdir/builds/circt/bin/circt-opt+0x6f12e15)
Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions