Skip to content

[mlir] --resolve-ranked-shaped-type-result-dims crashed with assertion failure "idx < size()" #70180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Oct 25, 2023 · 1 comment · Fixed by #70774
Closed
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:memref

Comments

@ghost
Copy link

ghost commented Oct 25, 2023

git version: b745ce9

system: Ubuntu 20.04.6 LTS (Focal Fossa)

reproduced with: mlir-opt --resolve-ranked-shaped-type-result-dims a.mlir

a.mlir:

module {
  func.func private @func2() {
    %idx28 = index.constant 28
    %c19 = arith.constant 19 : index
    %c28 = arith.constant 28 : index
    %c29 = arith.constant 29 : index
    %3 = bufferization.alloc_tensor(%c29) : tensor<?xi16>
    %dim = tensor.dim %3, %idx28 : tensor<?xi16>
    %alloc_21 = memref.alloc(%c28) : memref<?x26x2xi32>
    %16 = affine.vector_load %alloc_21[%c28, %c19, %dim] : memref<?x26x2xi32>, vector<7xi32>
    vector.print %16 : vector<7xi32>
    return
  }
}

trace:

mlir-opt: /data/bin/llvm-project/llvm/include/llvm/ADT/SmallVector.h:294: T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type) [with T = mlir::OpFoldResult; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::reference = mlir::OpFoldResult&; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type = long unsigned int]: Assertion `idx < size()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /data/bin/llvm-project/build/bin/mlir-opt --resolve-ranked-shaped-type-result-dims a.mlir
 #0 0x0000555e8b4463af llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x15ca3af)
 #1 0x0000555e8b443444 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f189262c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f189211700b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f18920f6859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f18920f6729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f1892107fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x0000555e8c6d8095 (/data/bin/llvm-project/build/bin/mlir-opt+0x285c095)
 #8 0x0000555e8c6d8ad2 (anonymous namespace)::DimOfReifyRankedShapedTypeOpInterface<mlir::tensor::DimOp>::matchAndRewrite(mlir::tensor::DimOp, mlir::PatternRewriter&) const ResolveShapedTypeResultDims.cpp:0:0
 #9 0x0000555e8b8af0aa mlir::detail::OpOrInterfaceRewritePatternBase<mlir::tensor::DimOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x1a330aa)
#10 0x0000555e90c610b8 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/data/bin/llvm-project/build/bin/mlir-opt+0x6de50b8)
#11 0x0000555e8e04116c (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#12 0x0000555e8e0455db mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/bin/llvm-project/build/bin/mlir-opt+0x41c95db)
#13 0x0000555e8c6d9933 (anonymous namespace)::ResolveRankedShapeTypeResultDimsPass::runOnOperation() ResolveShapedTypeResultDims.cpp:0:0
#14 0x0000555e8df8c39e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x411039e)
#15 0x0000555e8df8c87a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x411087a)
#16 0x0000555e8df8d0a4 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x41110a4)
#17 0x0000555e8df7d96b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x0000555e8df7ee24 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
#19 0x0000555e8df7efd4 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
#20 0x0000555e8e07b8e4 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) (/data/bin/llvm-project/build/bin/mlir-opt+0x41ff8e4)
#21 0x0000555e8df782a7 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin/llvm-project/build/bin/mlir-opt+0x40fc2a7)
#22 0x0000555e8df7f2fb mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x41032fb)
#23 0x0000555e8b37ea1b main (/data/bin/llvm-project/build/bin/mlir-opt+0x1502a1b)
#24 0x00007f18920f8083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#25 0x0000555e8b416cde _start (/data/bin/llvm-project/build/bin/mlir-opt+0x159acde)
Aborted (core dumped)
@ghost ghost changed the title Title: [mlir] --resolve-ranked-shaped-type-result-dims crashed with assertion failure "idx < size()" [mlir] --resolve-ranked-shaped-type-result-dims crashed with assertion failure "idx < size()" Oct 25, 2023
@github-actions github-actions bot added the mlir label Oct 25, 2023
@knightXun
Copy link
Contributor

mark

@EugeneZelenko EugeneZelenko added the crash Prefer [crash-on-valid] or [crash-on-invalid] label Oct 27, 2023
matthias-springer added a commit to matthias-springer/llvm-project that referenced this issue Oct 31, 2023
Do not crash when the input IR is invalid, i.e., when the index of the dimension operand of a `tensor.dim`/`memref.dim` is out-of-bounds. This fixes llvm#70180.
matthias-springer added a commit that referenced this issue Oct 31, 2023
)

Do not crash when the input IR is invalid, i.e., when the index of the
dimension operand of a `tensor.dim`/`memref.dim` is out-of-bounds. This
fixes #70180.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:memref
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants