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

Slither crashes when calling an anonymous payable function #135

Closed
Xenomega opened this issue Jan 15, 2019 · 2 comments
Closed

Slither crashes when calling an anonymous payable function #135

Xenomega opened this issue Jan 15, 2019 · 2 comments
Labels
bug Something isn't working Legacy AST

Comments

@Xenomega
Copy link
Member

The following contract will crash slither:

contract C {
    function f() public {
    	function () external payable x;
        x.value(msg.value)();
    }
}

Stack trace:

ERROR:root:Traceback (most recent call last):
  File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 250, in main_impl
    (results, number_contracts) = process(filename, args, detector_classes, printer_classes)
  File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 35, in process
    slither = Slither(filename, args.solc, args.disable_solc_warnings, args.solc_args, ast)
  File "c:\users\vyper\documents\github\slither\slither\slither.py", line 41, in __init__
    self._analyze_contracts()
  File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 210, in _analyze_contracts
    self._convert_to_slithir()
  File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 336, in _convert_to_slithir
    contract.convert_expression_to_slithir()
  File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\contract.py", line 367, in convert_expression_to_slithir
    func.generate_slithir_and_analyze()
  File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\function.py", line 927, in generate_slithir_and_analyze
    node.slithir_generation()
  File "c:\users\vyper\documents\github\slither\slither\core\cfg\node.py", line 508, in slithir_generation
    self._find_read_write_call()
  File "c:\users\vyper\documents\github\slither\slither\core\cfg\node.py", line 551, in _find_read_write_call
    self._high_level_calls.append((ir.destination.type.type, ir.function))
AttributeError: 'FunctionType' object has no attribute 'type'
@Xenomega
Copy link
Member Author

Xenomega commented Jan 16, 2019

This may be a separate issue, but the stack trace leads to the same place (albeit under different circumstances), so I will share it here:

Slither errors when parsing a function call that is provided through a library, for a struct member (if that struct has the same name as the contract/shadows it):

library TestLib {
  function test(uint a) internal pure returns (uint) {
    return a;
  }
}

contract ShadowedName {

  using TestLib for uint;

  struct ShadowedName {
    uint y;
  }

  function f(uint256 id1, uint256 id2) public {
    ShadowedName memory structInstance;
    structInstance.y = (structInstance.y).test();
  }
}

Stack trace:

Traceback (most recent call last):
  File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 250, in main_impl
    (results, number_contracts) = process(filename, args, detector_classes, printer_classes)
  File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 35, in process
    slither = Slither(filename, args.solc, args.disable_solc_warnings, args.solc_args, ast)
  File "c:\users\vyper\documents\github\slither\slither\slither.py", line 41, in __init__
    self._analyze_contracts()
  File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 214, in _analyze_contracts
    self._convert_to_slithir()
  File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 349, in _convert_to_slithir
    raise type(e)(f"{e} occurs in file: {contract.source_mapping_str}\n")
AttributeError: 'NoneType' object has no attribute 'type'

@montyly montyly added the bug Something isn't working label Jan 17, 2019
@montyly
Copy link
Member

montyly commented Jan 18, 2019

Notes:

  • The first example is fixed in dev
  • The second example only crashes with the legacy AST

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

No branches or pull requests

2 participants