Skip to content
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

[SV] Canonicalizer ASAN failure #7563

Closed
dtzSiFive opened this issue Aug 31, 2024 · 0 comments · Fixed by #7564
Closed

[SV] Canonicalizer ASAN failure #7563

dtzSiFive opened this issue Aug 31, 2024 · 0 comments · Fixed by #7564

Comments

@dtzSiFive
Copy link
Contributor

Input I had locally presently causes ASAN failure w/canonicalizer.

Input:

hw.module @Test(in %x : i8, in %clock: i1) {
  // All of these are equivalent to `var logic x` .

  // logic-type variable, assign to x.
  %logicvar = sv.logic : !hw.inout<i8>
  sv.assign %logicvar, %x : i8

  // Same but use keyword "reg" (reg x; = var logic x;)
  %regvar = sv.reg : !hw.inout<i8>
  sv.assign %regvar, %x : i8

  // sv.reg supports initialization operand, demonstrate.
  %regwithinit = sv.reg init %x : !hw.inout<i8>
}

ASAN report snippet:

=================================================================
==4169766==ERROR: AddressSanitizer: heap-use-after-free on address 0x50d000000640 at pc 0x564cb22e62ba bp 0x7ffd4dcf1670 sp 0x7ffd4dcf1668
READ of size 8 at 0x50d000000640 thread T0
    #0 0x564cb22e62b9 in mlir::detail::IROperandBase::getNextOperandUsingThisValue() /home/will/src/sifive/circt/llvm/llvm/../mlir/include/mlir/IR/UseDefLists.h:43:58
    #1 0x564cb22e62b9 in mlir::ValueUseIterator<mlir::OpOperand>::operator++() /home/will/src/sifive/circt/llvm/llvm/../mlir/include/mlir/IR/UseDefLists.h:322:39
    #2 0x564cb22e62b9 in circt::sv::RegOp::canonicalize(circt::sv::RegOp, mlir::PatternRewriter&) /home/will/src/sifive/circt/lib/Dialect/SV/SVOps.cpp:311:18

At a glance, we're deleting users while iterating over them (and may delete operations using this more than once twice / invalidate the list).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant