llvm / llvm/circt

[circt-reduce] Assertion Triggered segfault

Open
#9,029 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

This issue can be reproduced by the attached mlirbc and circt-reduce built at 40962a320. An easy fix can be introduced to guard the isBeforeInBlock, but I think it exposes a deeper issue with other passes.

[merged.mlirbc.tar.gz](https://github.com/user-attachments/files/22567484/merged.mlirbc.tar.gz)

Stacktrace:
```
circt-reduce: /scratch/tianruiwei/tmp/circt/llvm/mlir/lib/IR/Operation.cpp:387: bool mlir::Operation::isBeforeInBlock(mlir::Operation*): Assertion `other && other->block == block && "Expected other operation to have the same parent block."' failed.
PLEASE submit a bug report to https://github.com/llvm/circt and include the crash backtrace.
Stack dump:
0. Program arguments: circt-reduce merged.mlirbc -keep-best -o Reduced.mlirbc --exclude=canonicalize -emit-bytecode -test=test.sh
#0 0x000060e2ebc0bfb9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /scratch/tianruiwei/tmp/circt/llvm/llvm/lib/Support/Unix/Signals.inc:838:3
#1 0x000060e2ebc08f84 llvm::sys::RunSignalHandlers() /scratch/tianruiwei/tmp/circt/llvm/llvm/lib/Support/Signals.cpp:104:20
#2 0x000060e2ebc0979c SignalHandler(int, siginfo_t*, void*) /scratch/tianruiwei/tmp/circt/llvm/llvm/lib/Support/Unix/Signals.inc:426:14
#3 0x00007dc195a3e540 (/usr/lib/libc.so.6+0x3e540)
#4 0x00007dc195a9894c (/usr/lib/libc.so.6+0x9894c)
#5 0x00007dc195a3e410 raise (/usr/lib/libc.so.6+0x3e410)
#6 0x00007dc195a2557a abort (/usr/lib/libc.so.6+0x2557a)
#7 0x00007dc195a254e3 __assert_perror_fail (/usr/lib/libc.so.6+0x254e3)
#8 0x000060e2ebb9abb2 llvm::ilist_traits::addNodeToList(mlir::Operation*) (.cold) /scratch/tianruiwei/tmp/circt/llvm/mlir/lib/IR/Operation.cpp:502:74
#9 0x000060e2ec9ccec0 (anonymous namespace)::ConnectForwarder::match(mlir::Operation*) /scratch/tianruiwei/tmp/circt/lib/Dialect/FIRRTL/FIRRTLReductions.cpp:935:17
#10 0x000060e2ebbca324 circt::Reduction::matches(mlir::Operation*, llvm::function_ref) /scratch/tianruiwei/tmp/circt/include/circt/Reduce/Reduction.h:52:13
#11 0x000060e2ebbca324 operator() /scratch/tianruiwei/tmp/circt/tools/circt-reduce/circt-reduce.cpp:278:24
#12 0x000060e2ebbca324 void llvm::function_ref::callback_fn(long, mlir::Operation*) /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:52
#13 0x000060e2ebbcd198 llvm::ilist_iterator, false, false>::operator++() /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/ilist_iterator.h:187:13
#14 0x000060e2ebbcd198 llvm::ilist_iterator, false, false>::operator++(int) /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/ilist_iterator.h:197:5
#15 0x000060e2ebbcd198 llvm::early_inc_iterator_impl, false, false>>::operator*() /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/STLExtras.h:599:22
#16 0x000060e2ebbcd198 void mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) /scratch/tianruiwei/tmp/circt/llvm/mlir/include/mlir/IR/Visitors.h:145:7
#17 0x000060e2ebbcd198 llvm::ilist_iterator, false, false>::operator++() /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/ilist_iterator.h:187:13
#18 0x000060e2ebbcd198 llvm::ilist_iterator, false, false>::operator++(int) /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/ilist_iterator.h:197:5
#19 0x000060e2ebbcd198 llvm::early_inc_iterator_impl, false, false>>::operator*() /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/STLExtras.h:599:22
#20 0x000060e2ebbcd198 void mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) /scratch/tianruiwei/tmp/circt/llvm/mlir/include/mlir/IR/Visitors.h:145:7
#21 0x000060e2ebbcd198 llvm::ilist_iterator, false, false>::operator++() /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/ilist_iterator.h:187:13
#22 0x000060e2ebbcd198 llvm::ilist_iterator, false, false>::operator++(int) /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/ilist_iterator.h:197:5
#23 0x000060e2ebbcd198 llvm::early_inc_iterator_impl, false, false>>::operator*() /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/STLExtras.h:599:22
#24 0x000060e2ebbcd198 void mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) /scratch/tianruiwei/tmp/circt/llvm/mlir/include/mlir/IR/Visitors.h:145:7
#25 0x000060e2ebbc319a llvm::SmallVectorBase::size() const /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/SmallVector.h:79:32
#26 0x000060e2ebbc319a llvm::SmallVectorTemplateCommon::end() /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/SmallVector.h:270:41
#27 0x000060e2ebbc319a decltype(fp.end()) std::end>(llvm::SmallVector&) /usr/include/c++/15.2.1/bits/range_access.h:80:24
#28 0x000060e2ebbc319a decltype(end(forward&>(fp))) llvm::adl_detail::end_impl&>(llvm::SmallVector&) /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/ADL.h:37:13
#29 0x000060e2ebbc319a decltype(end_impl(forward&>(fp))) llvm::adl_end&>(llvm::SmallVector&) /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/ADL.h:88:30
#30 0x000060e2ebbc319a stable_sort&, execute(mlir::MLIRContext&):: > /scratch/tianruiwei/tmp/circt/llvm/llvm/include/llvm/ADT/STLExtras.h:2044:19
#31 0x000060e2ebbc319a execute /scratch/tianruiwei/tmp/circt/tools/circt-reduce/circt-reduce.cpp:288:24
#32 0x000060e2ebbc319a main /scratch/tianruiwei/tmp/circt/tools/circt-reduce/circt-reduce.cpp:532:14
#33 0x00007dc195a27675 (/usr/lib/libc.so.6+0x27675)
#34 0x00007dc195a27729 __libc_start_main (/usr/lib/libc.so.6+0x27729)
#35 0x000060e2ebbc7f95 _start (/scratch/tianruiwei/tmp/circt/build/bin/circt-reduce+0x1cef95)
Aborted (core dumped) circt-reduce merged.mlirbc -keep-best -o Reduced.mlirbc --exclude=canonicalize -emit-bytecode -test=test.sh
```

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 the attached merged.mlirbc and the circt-reduce command shown in the report. Start at ConnectForwarder::match in lib/Dialect/FIRRTL/FIRRTLReductions.cpp:935, then inspect its use through tools/circt-reduce/circt-reduce.cpp. Done means the reproducer no longer triggers the MLIR parent-block assertion and the underlying reduction behavior is covered or explained.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, tooling
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.