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]: Infinite loop in SlitherCompilationUnitSolc._analyze_all_enums #1758

Closed
romcyncynatus opened this issue Mar 14, 2023 · 4 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@romcyncynatus
Copy link

Describe the issue:

When analyzing certain contracts, for example, 0x757bc268bd50da88b2d0cf1966652b18e56ca803, an infinite loop in SlitherCompilationUnitSolc._analyze_all_enums is encountered. The contracts_to_be_analyzed list seems to contain only a single contract that is being added and removed repeatedly.

Code example to reproduce the issue:

# https://etherscan.io/address/0x757bc268bd50da88b2d0cf1966652b18e56ca803
import slither
s = slither.Slither('0x757bc268bd50da88b2d0cf1966652b18e56ca803')

Version:

0.9.2

Relevant log output:

>>> import slither
>>> s = slither.Slither('0x757bc268bd50da88b2d0cf1966652b18e56ca803')
WARNING:CryticCompile:Warning: @uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol: Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.

Warning: contracts/core/work/ContributionBoard.sol:390:5: Warning: Function state mutability can be restricted to view
    function _beforeTokenTransfer(
    ^ (Relevant source part starts here and spans across multiple lines).


^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rom/projects/smart-contracts-similarity/venv/lib/python3.10/site-packages/slither/slither.py", line 133, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/home/rom/projects/smart-contracts-similarity/venv/lib/python3.10/site-packages/slither/slither.py", line 139, in _init_parsing_and_analyses
    parser.parse_contracts()
  File "/home/rom/projects/smart-contracts-similarity/venv/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 496, in parse_contracts
    self._analyze_all_enums(contracts_to_be_analyzed)
  File "/home/rom/projects/smart-contracts-similarity/venv/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 542, in _analyze_all_enums
    for father in contract.underlying_contract.inheritance
  File "/home/rom/projects/smart-contracts-similarity/venv/lib/python3.10/site-packages/slither/solc_parsing/declarations/contract.py", line 92, in underlying_contract
    @property
KeyboardInterrupt
@romcyncynatus romcyncynatus added the bug-candidate Bugs reports that are not yet confirmed label Mar 14, 2023
@0xalpharush
Copy link
Contributor

0xalpharush commented Mar 14, 2023

Whenever names are reused like the following, Slither may not correctly resolve inheritance and cause a loop

import {
    ERC20Burnable,
    ERC20 as _ERC20
} from "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";

/**
 * @title Commit Token
 * @notice Commit Token is used for redeeming stable coins, buying crypto products
 *      from the village market and mining vision tokens. It is minted by the admin and
 *      given to the contributors. The amount of mintable token is limited to the balance
 *      of redeemable stable coins. Therefore, it's 1:1 pegged to the given stable coin
 *      or expected to have higher value than the redeemable coin values.
 */
contract ERC20 is ERC20Burnable {

This is being tracked as part of #1452

@0xalpharush 0xalpharush added the bug Something isn't working label Mar 14, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: Infinite loop in SlitherCompilationUnitSolc._analyze_all_enums [Bug]: Infinite loop in SlitherCompilationUnitSolc._analyze_all_enums Mar 14, 2023
@0xalpharush 0xalpharush removed the bug-candidate Bugs reports that are not yet confirmed label Mar 14, 2023
@0xalpharush 0xalpharush added this to the 0.9.4 milestone Apr 4, 2023
@Yhtiyar
Copy link

Yhtiyar commented Aug 9, 2023

Facing the same problem when running slither on this repo: https://github.com/xdao-app/xdao-contracts
There are no redefines of the imports. There are usages of using X for Y, but it feels like it should not affect.

@0xalpharush
Copy link
Contributor

@Yhtiyar What version of slither are you running?

@Yhtiyar
Copy link

Yhtiyar commented Aug 9, 2023

0.9.6

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