llvm / llvm/circt

[FIRRTL] Crash with malformed annotation target

Open
#5,440 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

`firtool ./test.fir` on the follow input:
```firrtl
circuit Foo: %[[
{
"class":"firrtl.transforms.DontTouchAnnotation",
"target":"~Foo|Foo.w"
}
]]
module Foo:
wire w : UInt<1>
```
Crashes with:
```
firtool: /scratch/verif/aryoung/plato-circt-tester/circt/lib/Dialect/FIRRTL/FIRRTLAnnotationHelper.cpp:204: std::optional circt::firrtl::resolveEntities(circt::firrtl::TokenAnnoTarget, circt::firrtl::CircuitOp, mlir::SymbolTable &, circt::firrtl::CircuitTargetCache &): Assertion `path.component.empty()' failed.
```
Which is an assert [here](https://github.com/llvm/circt/blob/main/lib/Dialect/FIRRTL/FIRRTLAnnotationHelper.cpp#L204). It seems like the assertion should be changed to a regular error message.

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

Start in lib/Dialect/FIRRTL/FIRRTLAnnotationHelper.cpp at the assertion around line 204, then reproduce the failure with the firtool input in the issue. Replace the assertion failure with a regular error for this malformed annotation target, and verify that firtool reports the error without crashing.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.