From 671caa39cedd804be73633198e1422c08fb7122d Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 30 Oct 2023 07:43:10 -0500 Subject: [PATCH 1/2] use iterative algo to prevent exceeding recursion limit --- slither/solc_parsing/declarations/function.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 59940ec1cd..f51474770f 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -1108,9 +1108,12 @@ def _parse_unchecked_block(self, block: Dict, node: NodeSolc, scope): def _update_reachability(self, node: Node) -> None: if node.is_reachable: return - node.set_is_reachable(True) - for son in node.sons: - self._update_reachability(son) + worklist = [node] + while worklist: + current = worklist.pop() + current.set_is_reachable(True) + worklist.extend(current.sons) + def _parse_cfg(self, cfg: Dict) -> None: From ba4d5a772219a7af75c85fb77b1d6bca492374a7 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 30 Oct 2023 07:55:35 -0500 Subject: [PATCH 2/2] proper fixpoint --- slither/solc_parsing/declarations/function.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index f51474770f..c1b94661d1 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -1106,14 +1106,13 @@ def _parse_unchecked_block(self, block: Dict, node: NodeSolc, scope): return node def _update_reachability(self, node: Node) -> None: - if node.is_reachable: - return worklist = [node] while worklist: current = worklist.pop() - current.set_is_reachable(True) - worklist.extend(current.sons) - + # fix point + if not current.is_reachable: + current.set_is_reachable(True) + worklist.extend(current.sons) def _parse_cfg(self, cfg: Dict) -> None: