Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: delegatecall_in_loop detector fails on some custom errors #1174

Closed
Tracked by #1252
axic opened this issue Apr 16, 2022 · 2 comments
Closed
Tracked by #1252

[Bug]: delegatecall_in_loop detector fails on some custom errors #1174

axic opened this issue Apr 16, 2022 · 2 comments
Labels
bug Something isn't working High Priority

Comments

@axic
Copy link

axic commented Apr 16, 2022

Describe the issue:

This is probably related to #1173. Some detectors, like delegatecall_in_loop, crash the parser with some custom error cases.

Code example to reproduce the issue:

This is as far as I got minimizing the example:

contract A {
    error E(A a);

    function f() payable external {
      g();
    }
    
    function g() private {
      bool something = h();
      if (something) {
        revert E(this);
      }
    }

    function h() private returns (bool something) {
    }
}

The revert E(this); line is causing the issue.

Version:

0.8.2

Relevant log output:

Missing function Variable not found: E(A) (context A)
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 743, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 84, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 69, in process_single
    return _process(slither, detector_classes, printer_classes)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 110, in _process
    detector_results = slither.run_detectors()
  File "/opt/homebrew/lib/python3.9/site-packages/slither/slither.py", line 203, in run_detectors
    results = [d.detect() for d in self._detectors]
  File "/opt/homebrew/lib/python3.9/site-packages/slither/slither.py", line 203, in <listcomp>
    results = [d.detect() for d in self._detectors]
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/abstract_detector.py", line 152, in detect
    for r in [output.data for output in self._detect()]:
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 89, in _detect
    values = detect_delegatecall_in_loop(c)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 13, in detect_delegatecall_in_loop
    delegatecall_in_loop(f.entry_point, 0, [], results)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 41, in delegatecall_in_loop
    delegatecall_in_loop(son, in_loop_counter, visited, results)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 38, in delegatecall_in_loop
    delegatecall_in_loop(ir.function.entry_point, in_loop_counter, visited, results)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 41, in delegatecall_in_loop
    delegatecall_in_loop(son, in_loop_counter, visited, results)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 38, in delegatecall_in_loop
    delegatecall_in_loop(ir.function.entry_point, in_loop_counter, visited, results)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 25, in delegatecall_in_loop
    if node.type == NodeType.STARTLOOP:
AttributeError: 'NoneType' object has no attribute 'type'
None
Error in .
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 743, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 84, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 69, in process_single
    return _process(slither, detector_classes, printer_classes)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 110, in _process
    detector_results = slither.run_detectors()
  File "/opt/homebrew/lib/python3.9/site-packages/slither/slither.py", line 203, in run_detectors
    results = [d.detect() for d in self._detectors]
  File "/opt/homebrew/lib/python3.9/site-packages/slither/slither.py", line 203, in <listcomp>
    results = [d.detect() for d in self._detectors]
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/abstract_detector.py", line 152, in detect
    for r in [output.data for output in self._detect()]:
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 89, in _detect
    values = detect_delegatecall_in_loop(c)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 13, in detect_delegatecall_in_loop
    delegatecall_in_loop(f.entry_point, 0, [], results)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 41, in delegatecall_in_loop
    delegatecall_in_loop(son, in_loop_counter, visited, results)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 38, in delegatecall_in_loop
    delegatecall_in_loop(ir.function.entry_point, in_loop_counter, visited, results)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 41, in delegatecall_in_loop
    delegatecall_in_loop(son, in_loop_counter, visited, results)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 38, in delegatecall_in_loop
    delegatecall_in_loop(ir.function.entry_point, in_loop_counter, visited, results)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/detectors/statements/delegatecall_in_loop.py", line 25, in delegatecall_in_loop
    if node.type == NodeType.STARTLOOP:
AttributeError: 'NoneType' object has no attribute 'type'
@axic axic added the bug-candidate Bugs reports that are not yet confirmed label Apr 16, 2022
@montyly montyly added bug Something isn't working High Priority and removed bug-candidate Bugs reports that are not yet confirmed labels Apr 27, 2022
@montyly
Copy link
Member

montyly commented Apr 27, 2022

Hi @axic, thanks for reporting this

I confirm that this is still present with 0.8.3

@0xalpharush 0xalpharush changed the title [Bug-Candidate]: delegatecall_in_loop detector fails on some custom errors [Bug]: delegatecall_in_loop detector fails on some custom errors Jun 17, 2022
@0xalpharush 0xalpharush mentioned this issue Jun 22, 2022
17 tasks
@gsangeryee
Copy link

Some impacted detectors include: delegatecall-loop, msg-value-loop, calls-loop, costly-loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working High Priority
Projects
None yet
Development

No branches or pull requests

4 participants