fraig_restore: stack overflow when a representative chain has a cycle longer than two - #556
Open
marcelwa wants to merge 1 commit into
Open
fraig_restore: stack overflow when a representative chain has a cycle longer than two#556marcelwa wants to merge 1 commit into
marcelwa wants to merge 1 commit into
Conversation
… two
`Abc_NtkHaigResetReprs` normalises the `pData` representative chain before walking it
with `Hop_ObjRepr`, and its normalisation handles a self-loop and a two-node cycle
("the strange situation of double-loop"). A cycle of three or more survives it, and
the very next loop calls `Hop_ObjRepr` on every object; `Hop_ObjRepr` recurses on
`pObj->pData` until it reaches NULL or a self-loop, so on a longer cycle it recurses
until the stack is gone and the process dies of SIGSEGV with no diagnostic.
Observed on `mem_ctrl` from the EPFL suite under a two-round `fraig_store`/
`fraig_restore` pipeline, where the second round's candidate set contains both freshly
synthesised AIGs and the strashed expansion of a cover mapped from the first round's
choice network. 521105 identical `Hop_ObjRepr` frames, entered from
`Abc_NtkHaigResetReprs` at abcHaig.c:478 by way of `fraig_restore` ->
`Abc_NtkFraigRestore` -> `Abc_NtkFraigPartitioned` -> `Abc_NtkPartStitchChoices` ->
`Abc_NtkHopRemoveLoops`.
Floyd's algorithm finds a cycle of any length in constant space. A detected cycle is
broken the way the two-node case was broken: the meeting node becomes its own
representative. With this change the same run completes in 337 s.
(cherry picked from commit 00e4b34)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We hit a reproducible SIGSEGV in
fraig_restoreand would like to check our reading of the code before calling it a bug.Abc_NtkHaigResetReprs(src/base/abci/abcHaig.c) normalises thepDatarepresentative chain and handles exactly two shapes, a self-loop and a two-node cycle — the comment there calls the second one "the strange situation of double-loop" — but the very next loop in the same function callsHop_ObjRepron every object, andHop_ObjReprrecurses onpObj->pDatauntil it reachesNULLor a self-loop, so a cycle of three or more recurses until the stack is gone and the process dies with no diagnostic; we see 521105 identicalHop_ObjReprframes entered atabcHaig.c:478, by way offraig_restore->Abc_NtkFraigRestore->Abc_NtkFraigPartitioned->Abc_NtkPartStitchChoices->Abc_NtkHopRemoveLoops. Attached is a reproducer that is three AIGER files derived from EPFLmem_ctrland a four-line script (read_aiger; strash; fraig_storeon each, then onefraig_restore): it exits with signal 11 on master at c6e8823 after about three minutes, it completes with this patch, and dropping any one of the three files makes it go away — the ingredient that seems to matter is that one of the stored networks is the re-strashed expansion of a cover that was mapped from an earlierfraig_restore's choice network, which gives a denser equivalence structure than a plain set of synthesis variants. The patch generalises the existing normalisation from cycles of length two to cycles of any length using Floyd's algorithm and breaks a detected cycle the way the two-node case already did, by making the meeting node its own representative; it is constant space, it sits inside a loop that already visits every object, and it is inert where there is no cycle — a single-roundfraig_store/fraig_restorepipeline gives byte-identical mapped netlists with and without it (adder 212 LUTs / 84 levels, cavlc 111/6, i2c 258/7). Our question is whether a cycle longer than two is supposed to be impossible at this point: if it is, the real defect is wherever the chain gets built and this patch only hides it, and we would rather know that and close this.Attachment archive