llvm / llvm/circt

[FIRRTL] Crash with out-of-bounds Index

Open
#4,753 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug FIRRTL
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

I noticed that the following is crashing:

```
circuit Foo:
module Foo:
input a: UInt<8>[3]
output b: UInt<8>

b <= a[UInt<99>(300)]
```

This throws an error (doesn't exit) and then crashes (`firtool Foo.fir`):

```
Foo.fir:6:12: error: out of range index '300' in vector type '!firrtl.vector, 3>'
b <= a[UInt<99>(300)]
^
LLVM ERROR: Failed to infer result type(s).
PLEASE submit a bug report to https://github.com/llvm/circt and include the crash backtrace.
Stack dump:
0. Program arguments: firtool Foo.fir
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 firtool 0x00000001039cf21d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 61
1 firtool 0x00000001039cf79b PrintStackTraceSignalHandler(void*) + 27
2 firtool 0x00000001039cd566 llvm::sys::RunSignalHandlers() + 134
3 firtool 0x00000001039d14cf SignalHandler(int) + 223
4 libsystem_platform.dylib 0x00007ff80f497dfd _sigtramp + 29
5 firtool 0x00000001037856e5 std::__1::__libcpp_deallocate(void*, unsigned long, unsigned long) + 85
6 libsystem_c.dylib 0x00007ff80f3cdd24 abort + 123
7 firtool 0x000000010389f2d4 llvm::report_fatal_error(llvm::Twine const&, bool) + 388
8 firtool 0x000000010389f145 llvm::report_fatal_error(char const*, bool) + 53
9 firtool 0x000000010479c065 circt::firrtl::SubindexOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::Value, unsigned int) + 533
10 firtool 0x0000000103ed526c circt::firrtl::SubindexOp mlir::OpBuilder::create, long long>(mlir::Location, mlir::detail::TypedValue&&, long long&&) + 220
11 firtool 0x0000000103ed4fd1 circt::firrtl::SubindexOp mlir::ImplicitLocOpBuilder::create, long long>(mlir::detail::TypedValue&&, long long&&) + 81
```

Contributor guide

No contributing guide indexed for this repository

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

Reproduce the failure with firtool Foo.fir using the FIRRTL circuit in the report. Start at circt::firrtl::SubindexOp::build, identified in the stack trace, and trace how the out-of-range diagnostic is handled; done means the invalid input reports the error without triggering the LLVM fatal crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.