slither icon indicating copy to clipboard operation
slither copied to clipboard

[Bug]: Slither fails analysing `raw_call` to `empty(address)`

Open trocher opened this issue 2 years ago • 1 comments

Describe the issue:

Slither crashes when given a Vyper contract containing a raw_call to empty(address)

Code example to reproduce the issue:

@external
def foo():
    raw_call(empty(address),b'')

Version:

0.10.0

Relevant log output:

Traceback (most recent call last):
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/core/cfg/node.py", line 918, in _find_read_write_call
    self._high_level_calls.append((ir.destination.type.type, ir.function))
AttributeError: 'NoneType' object has no attribute 'type'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/__main__.py", line 833, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/__main__.py", line 107, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/__main__.py", line 80, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/slither.py", line 144, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/slither.py", line 164, in _init_parsing_and_analyses
    raise e
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/slither.py", line 160, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/vyper_parsing/vyper_compilation_unit.py", line 63, in analyze_contracts
    self._convert_to_slithir()
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/vyper_parsing/vyper_compilation_unit.py", line 73, in _convert_to_slithir
    func.generate_slithir_and_analyze()
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/core/declarations/function.py", line 1767, in generate_slithir_and_analyze
    node.slithir_generation()
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/core/cfg/node.py", line 718, in slithir_generation
    self._find_read_write_call()
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/core/cfg/node.py", line 921, in _find_read_write_call
    raise SlitherException(
slither.exceptions.SlitherException: Function not found on IR: TUPLE_0(None) = HIGH_LEVEL_CALL, dest:TMP_0(None), function:raw_call, arguments:['0x']  .
Node: EXPRESSION empty()().raw_call(0x) (code.vy#5-6)
Function: foo
Please try compiling with a recent Solidity version. 'NoneType' object has no attribute 'type'
ERROR:root:Error:
ERROR:root:Function not found on IR: TUPLE_0(None) = HIGH_LEVEL_CALL, dest:TMP_0(None), function:raw_call, arguments:['0x']  .
Node: EXPRESSION empty()().raw_call(0x) (code.vy#5-6)
Function: foo
Please try compiling with a recent Solidity version. 'NoneType' object has no attribute 'type'
ERROR:root:Please report an issue to https://github.com/crytic/slither/issues

trocher avatar Oct 19 '23 08:10 trocher

We aren't currently inferring the return type for empty(...). There's still some work to follow up on the initial implementation https://github.com/crytic/slither/pull/2099. Some of this will follow addressing https://github.com/vyperlang/vyper/issues/3581 so that return types are provided for generic builtins

0xalpharush avatar Oct 19 '23 13:10 0xalpharush