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]: slither 0.8.3 crashing #1266

Closed
thedavidmeister opened this issue Jul 5, 2022 · 7 comments
Closed

[Bug]: slither 0.8.3 crashing #1266

thedavidmeister opened this issue Jul 5, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@thedavidmeister
Copy link

thedavidmeister commented Jul 5, 2022

Describe the issue:

Missing function 'value'
Missing function 'value'
Missing function 'value'
Missing function 'value'
Missing function 'value'
Missing function 'value'
Missing function 'value'
Missing function Variable not found: initializer (context Sale)
Traceback (most recent call last):
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/__main__.py", line 744, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/__main__.py", line 87, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/__main__.py", line 72, in process_single
    return _process(slither, detector_classes, printer_classes)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/__main__.py", line 113, in _process
    detector_results = slither.run_detectors()
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/slither.py", line 201, in run_detectors
    results = [d.detect() for d in self._detectors]
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/slither.py", line 201, in <listcomp>
    results = [d.detect() for d in self._detectors]
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/abstract_detector.py", line 152, in detect
    for r in [output.data for output in self._detect()]:
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy_eth.py", line 93, in _detect
    super()._detect()
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 303, in _detect
    self.detect_reentrancy(c)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 290, in detect_reentrancy
    self._explore(function.entry_point, [])
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 282, in _explore
    self._explore(son, visited)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 282, in _explore
    self._explore(son, visited)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 282, in _explore
    self._explore(son, visited)
  [Previous line repeated 1 more time]
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 267, in _explore
    contains_call = fathers_context.analyze_node(node, self)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 159, in analyze_node
    if detector.can_callback(ir):
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line [228](https://github.com/beehive-innovation/rain-protocol/runs/7194366865?check_suite_focus=true#step:4:229), in can_callback
    return isinstance(ir, Call) and ir.can_reenter()
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/slithir/operations/library_call.py", line 27, in can_reenter
    return self.function.can_reenter(callstack)
AttributeError: 'NoneType' object has no attribute 'can_reenter'
None
Error in .
Traceback (most recent call last):
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/__main__.py", line 744, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/__main__.py", line 87, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/__main__.py", line 72, in process_single
    return _process(slither, detector_classes, printer_classes)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/__main__.py", line 113, in _process
    detector_results = slither.run_detectors()
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/slither.py", line 201, in run_detectors
    results = [d.detect() for d in self._detectors]
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/slither.py", line 201, in <listcomp>
    results = [d.detect() for d in self._detectors]
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/abstract_detector.py", line 152, in detect
    for r in [output.data for output in self._detect()]:
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy_eth.py", line 93, in _detect
    super()._detect()
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 303, in _detect
    self.detect_reentrancy(c)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 290, in detect_reentrancy
    self._explore(function.entry_point, [])
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 282, in _explore
    self._explore(son, visited)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 282, in _explore
    self._explore(son, visited)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 282, in _explore
    self._explore(son, visited)
  [Previous line repeated 1 more time]
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 267, in _explore
    contains_call = fathers_context.analyze_node(node, self)
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 159, in analyze_node
    if detector.can_callback(ir):
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/detectors/reentrancy/reentrancy.py", line 228, in can_callback
    return isinstance(ir, Call) and ir.can_reenter()
  File "/nix/store/dyb0f0f2j23qgy5bdgfhjxfhrwks48as-python3.10-slither-analyzer-0.8.3/lib/python3.10/site-packages/slither/slithir/operations/library_call.py", line 27, in can_reenter
    return self.function.can_reenter(callstack)
AttributeError: 'NoneType' object has no attribute 'can_reenter'

Getting this cryptic set of errors when running slither . --npx-disable --filter-paths="contracts/test" --exclude-dependencies

Can see this in CI: https://github.com/beehive-innovation/rain-protocol/runs/7194366865?check_suite_focus=true

I tried removing top level constants and enums as I saw this was causing others issues, but it didn't seem to help

Code example to reproduce the issue:

https://github.com/beehive-innovation/rain-protocol/runs/7194366865?check_suite_focus=true

Version:

0.8.3

Relevant log output:

No response

@thedavidmeister thedavidmeister added the bug-candidate Bugs reports that are not yet confirmed label Jul 5, 2022
@0xalpharush
Copy link
Contributor

@thedavidmeister Would you mind seeing if this branch fixes the issue you ran into? #1267

@thedavidmeister
Copy link
Author

@0xalpharush hey sorry, i have no python experience and after getting about 5 cryptic (to me) errors deep in the "virtual env" setup i had to stop

the repository with the errors is public though, you should be able to pull it and run slither on it against develop to see the problem

i removed all custom errors from my solidity code (which i believe is what the linked issue is about) and am still seeing the same errors when i run slither

@0xalpharush
Copy link
Contributor

Thanks for checking. I'm looking into it. As of now, I expect it is in edge case in how slither parses assembly. I'll working on a fix.

@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Jul 13, 2022
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: slither 0.8.3 crashing [Bug]: slither 0.8.3 crashing Jul 13, 2022
@0xalpharush
Copy link
Contributor

The first issue has to do with the declaration of yul variables without assigning them:

    function sub(uint256 operand_, uint256 stackTopLocation_)
        internal
        pure
        returns (uint256)
    {
        assembly {
            let location_ := sub(stackTopLocation_, mul(operand_, 0x20))
            let accumulator_ := mload(location_)
            let intermediate_
            for {
                let cursor_ := add(location_, 0x20)
            } lt(cursor_, stackTopLocation_) {
                cursor_ := add(cursor_, 0x20)
            } {
                intermediate_ := sub(accumulator_, mload(cursor_))
                // Adapted from Open Zeppelin safe math.
                if gt(intermediate_, accumulator_) {
                    revert(0, 0)
                }
                accumulator_ := intermediate_
            }
            mstore(location_, accumulator_)
            stackTopLocation_ := add(location_, 0x20)
        }

        return stackTopLocation_;
    }

This code does not handle this edge case:

def parse_yul_variable_declaration(
root: YulScope, node: YulNode, ast: Dict
) -> Optional[Expression]:
"""
We already created variables in the conversion phase, so just do
the assignment
"""
if not ast["value"]:
return None
return _parse_yul_assignment_common(root, node, ast, "variables")

The second issue regarding the initializer modifier should be fixed by #1227

@thedavidmeister
Copy link
Author

thedavidmeister commented Jul 14, 2022

@0xalpharush when do you expect these fixes you are referencing to be available in a release?

is there a workaround i can implement in the meantime?

@0xalpharush
Copy link
Contributor

I haven't tested it but I think let intermediate_ := 0x0 may bypass the first error. Not sure about the second issue unfortunately.

@engn33r
Copy link

engn33r commented Jan 1, 2023

I had this same issue with slither 0.8.3, but updating to 0.9.1 fixed the issue. This issue can be closed as far as I can tell.

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

No branches or pull requests

3 participants