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]: AttributeError: 'NoneType' object has no attribute 'can_reenter' #1253

Closed
mehtaculous opened this issue Jun 22, 2022 · 1 comment · Fixed by #1267
Closed

[Bug]: AttributeError: 'NoneType' object has no attribute 'can_reenter' #1253

mehtaculous opened this issue Jun 22, 2022 · 1 comment · Fixed by #1267
Labels
bug Something isn't working High Priority

Comments

@mehtaculous
Copy link

mehtaculous commented Jun 22, 2022

Describe the issue:

I seem to be getting the following error message for contracts with custom revert errors that are declared inside an imported interface but the contract itself does not directly inherit from the interface:

Example: revert IContract.InvalidSender(...)

AttributeError: 'NoneType' object has no attribute 'can_reenter'

This error goes away when the custom revert is either declared directly inside the contract itself or inside an interface that it inherits from. Is there a possible fix for this without having to make either of the specified changes?

Code example to reproduce the issue:

pragma solidity 0.8.13;

interface IContract {
    error InvalidSender(address required, address provided);
}

import {IContract} from "../interfaces/IContract.sol";

contract Metadata {
    address immutable controller;
    mapping(uint256 => string) private tokenMetadata;

    constructor(address _controller) {
        controller = _controller;
    }

    function setURI(uint256 _id, string memory _uri) external {
        if (msg.sender != controller)
            revert IContract.InvalidSender({required: controller, provided: msg.sender});

        tokenMetadata[_id] = _uri;
    }
}

Version:

0.8.3

Relevant log output:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/slither/__main__.py", line 744, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/usr/local/lib/python3.9/site-packages/slither/__main__.py", line 87, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/usr/local/lib/python3.9/site-packages/slither/__main__.py", line 72, in process_single
    return _process(slither, detector_classes, printer_classes)
  File "/usr/local/lib/python3.9/site-packages/slither/__main__.py", line 113, in _process
    detector_results = slither.run_detectors()
  File "/usr/local/lib/python3.9/site-packages/slither/slither.py", line 201, in run_detectors
    results = [d.detect() for d in self._detectors]
  File "/usr/local/lib/python3.9/site-packages/slither/slither.py", line 201, in <listcomp>
    results = [d.detect() for d in self._detectors]
  File "/usr/local/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 "/usr/local/lib/python3.9/site-packages/slither/detectors/reentrancy/reentrancy_eth.py", line 93, in _detect
    super()._detect()
  File "/usr/local/lib/python3.9/site-packages/slither/detectors/reentrancy/reentrancy.py", line 303, in _detect
    self.detect_reentrancy(c)
  File "/usr/local/lib/python3.9/site-packages/slither/detectors/reentrancy/reentrancy.py", line 290, in detect_reentrancy
    self._explore(function.entry_point, [])
  File "/usr/local/lib/python3.9/site-packages/slither/detectors/reentrancy/reentrancy.py", line 282, in _explore
    self._explore(son, visited)
  File "/usr/local/lib/python3.9/site-packages/slither/detectors/reentrancy/reentrancy.py", line 282, in _explore
    self._explore(son, visited)
  File "/usr/local/lib/python3.9/site-packages/slither/detectors/reentrancy/reentrancy.py", line 282, in _explore
    self._explore(son, visited)
  File "/usr/local/lib/python3.9/site-packages/slither/detectors/reentrancy/reentrancy.py", line 267, in _explore
    contains_call = fathers_context.analyze_node(node, self)
  File "/usr/local/lib/python3.9/site-packages/slither/detectors/reentrancy/reentrancy.py", line 159, in analyze_node
    if detector.can_callback(ir):
  File "/usr/local/lib/python3.9/site-packages/slither/detectors/reentrancy/reentrancy.py", line 228, in can_callback
    return isinstance(ir, Call) and ir.can_reenter()
  File "/usr/local/lib/python3.9/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'
@mehtaculous mehtaculous added the bug-candidate Bugs reports that are not yet confirmed label Jun 22, 2022
@0xalpharush
Copy link
Contributor

I believe this is the same as #1001. Thanks for providing a test case! That's very helpful

@0xalpharush 0xalpharush added bug Something isn't working High Priority and removed bug-candidate Bugs reports that are not yet confirmed labels Jun 22, 2022
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: AttributeError: 'NoneType' object has no attribute 'can_reenter' [Bug]: AttributeError: 'NoneType' object has no attribute 'can_reenter' Jun 22, 2022
@0xalpharush 0xalpharush linked a pull request Jul 7, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants