crytic / slither

Static Analyzer for Solidity and Vyper

Home Page:https://blog.trailofbits.com/2018/10/19/slither-a-solidity-static-analysis-framework/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RecursionError: maximum recursion depth exceeded

0xalpharush opened this issue · comments

I am seeing this issue even with --ignore-compile in a Foundry repo.

$ slither --version
0.9.2

Originally posted by @0xmichalis in #1146 (comment)

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/slither/__main__.py", line 834, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/__main__.py", line 98, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/__main__.py", line 76, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/opt/homebrew/lib/python3.10/site-packages/slither/slither.py", line 134, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/opt/homebrew/lib/python3.10/site-packages/slither/slither.py", line 144, in _init_parsing_and_analyses
    raise e
  File "/opt/homebrew/lib/python3.10/site-packages/slither/slither.py", line 140, in _init_parsing_and_analyses
    parser.parse_contracts()
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 519, in parse_contracts
    self._analyze_third_part(contracts_to_be_analyzed, libraries)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 629, in _analyze_third_part
    self._analyze_variables_modifiers_functions(contract)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 728, in _analyze_variables_modifiers_functions
    contract.analyze_content_functions()
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/declarations/contract.py", line 416, in analyze_content_functions
    function_parser.analyze_content()
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/declarations/function.py", line 286, in analyze_content
    self._parse_cfg(body)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/declarations/function.py", line 1074, in _parse_cfg
    self._remove_incorrect_edges()
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/declarations/function.py", line 1278, in _remove_incorrect_edges
    self._fix_try(node)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/declarations/function.py", line 1153, in _fix_try
    self._fix_catch(son, end_node)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/declarations/function.py", line 1161, in _fix_catch
    self._fix_catch(son, end_node)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/declarations/function.py", line 1161, in _fix_catch
    self._fix_catch(son, end_node)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/declarations/function.py", line 1161, in _fix_catch
    self._fix_catch(son, end_node)
  [Previous line repeated 1480 more times]
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/declarations/function.py", line 1156, in _fix_catch
    if not node.sons:
RecursionError: maximum recursion depth exceeded

Minimal Reproducer:

pragma solidity ^0.8.0;

interface ITest {
    function run() external returns (uint);
}

contract Test {

    function break_max_recursion(address addr) private {
        try ITest(addr).run() returns (uint rval) {
            for (uint i; i < rval; i++) {
            }
        } catch {
        }
        return; // need some statement here.
    }

}

Thanks for minimizing this @duckki!

Any update on this?

I'm having the same issue when trying to analyse the Foundation marketplace contracts.