lsils / mockturtle

C++ logic network library
MIT License
202 stars 136 forks source link

Bug in refactoring #571

Closed aletempiac closed 1 year ago

aletempiac commented 1 year ago

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

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 commented 1 year ago

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.

lee30sonia commented 1 year ago

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

aletempiac commented 1 year ago

Fixed in #607