llvm / llvm/llvm-project

[mlir] Assertion `idx < size() && "index out of bounds"' failed.

Open
#204,090 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

crash mlir
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

git version: 4281db2755459933c68aa95a17f2518ef8317889

system: `Ubuntu 18.04.6 LTS`

reproduce with: `mlir-opt -test-func-insert-arg a.mlir`

a.mlir:

```mlir
module {
llvm.func @f(%arg0: i1 {test.A}) attributes {test.insert_args = [[0], [1, 0]]} {
%0 = "emitc.constant"() <{value = 1 : index}> : () -> !emitc.size_t
%1 = "emitc.constant"() <{value = 0 : index}> : () -> !emitc.size_t
%2 = builtin.unrealized_conversion_cast %1 : !emitc.size_t to index
%3 = "emitc.constant"() <{value = 42 : index}> : () -> !emitc.size_t
%4 = builtin.unrealized_conversion_cast %3 : !emitc.size_t to index
%5 = "emitc.constant"() <{value = 1.000000e+00 : f32}> : () -> f32
scf.for %arg1 = %2 to %4 step %2 {
"test.foo"() : () -> ()
%6 = scf.for %arg2 = %2 to %4 step %2 iter_args(%arg3 = %5) -> (f32) {
%7 = emitc.cast %arg3 : f32 to ui32
%8 = emitc.cast %arg3 : f32 to ui32
%9 = emitc.add %7, %8 : (ui32, ui32) -> ui32
%10 = emitc.cast %9 : ui32 to f32
scf.yield %10 : f32
}
"test.bar"() : () -> ()
}
"test.b"() : () -> ()
}
llvm.func @_mlir_ciface_f(%arg0: i1 {test.A}) attributes {test.insert_args = [[0], [1, 0]]} {
llvm.call @f(%arg0) : (i1) -> ()
llvm.return
}
}

```

stack trace:

```
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/build/tools/mlir/include/mlir/IR/BuiltinAttributes.h.inc:466: Attribute mlir::ArrayAttr::operator[](unsigned int) const: Assertion `idx < size() && "index out of bounds"' failed.
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: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -test-func-insert-arg 21.mlir
#0 0x000055ae2a1e6cc8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x2023cc8)
#1 0x000055ae2a1e3b61 llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x2020b61)
#2 0x000055ae2a1e7de6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f56cb765420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f56cada200b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007f56cad81859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007f56cad81729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007f56cad81729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007f56cad92fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#9 0x000055ae2a9a9e88 (anonymous namespace)::TestFuncInsertArg::runOnOperation() TestFunc.cpp:0:0
#10 0x000055ae32b413f2 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa97e3f2)
#11 0x000055ae32b42234 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa97f234)
#12 0x000055ae32b4914a mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa98614a)
#13 0x000055ae32b48a7f mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa985a7f)
#14 0x000055ae2a295970 performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#15 0x000055ae2a294ba6 llvm::LogicalResult llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#16 0x000055ae32e95795 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xacd2795)
#17 0x000055ae2a28bc06 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20c8c06)
#18 0x000055ae2a28bfe5 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20c8fe5)
#19 0x000055ae2a28c345 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20c9345)
#20 0x000055ae2a1cc752 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x2009752)
#21 0x00007f56cad83083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#22 0x000055ae2a1cc28e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x200928e)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the `mlir-opt -test-func-insert-arg a.mlir` reproducer and inspect the `TestFunc.cpp` implementation identified by the stack trace, especially its ArrayAttr access. Confirm which `test.insert_args` entry causes the out-of-bounds assertion, then add a regression test using the supplied MLIR and verify the pass no longer aborts.

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.