mockturtle icon indicating copy to clipboard operation
mockturtle copied to clipboard

Bug in refactoring

Open aletempiac opened this issue 3 years ago • 2 comments

Describe the bug Refactoring can lead to segmentation fault which is detected by the assert at line 267 in mffc_view.

This is due to the use of reference counters to keep track of the fanout of the gates. Reference counters can be invalidated after a node substitution. Moreover there are some wrong updates to the reference counters. The right way of keeping the fanout information correct is to use directly the fanout size field of gates.

To Reproduce I haven't found a way of reproducing it using "standard'' mockturtle yet.

Environment

  • OS: Linux
  • Compiler: GCC 12.2
  • Compilation mode: DEBUG and RELEASE

Additional information I know how to solve the bug. I will find time to fix it properly in the next weeks. The proposed fix is to replace the use of reference counters with the fanout_size.

aletempiac avatar Oct 19 '22 21:10 aletempiac

There is also a bug in mffc_view. If a PI is in the MFFC, it appears one additional time in _nodes. In fact, it is added both at line 205 and after recurring at line 197. Consequently, its reference value would be increased by one additional time increasing its original value before calling mffc_view.

aletempiac avatar Oct 19 '22 23:10 aletempiac

Good to catch. Interestingly, there are like at least three different implementations of counting MFFCs in mockturtle, by different people 😅

lee30sonia avatar Oct 21 '22 15:10 lee30sonia

Fixed in #607

aletempiac avatar May 31 '23 14:05 aletempiac