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]: AssertionError in UserDefinedType.__init__() #1783

Closed
webthethird opened this issue Mar 20, 2023 · 2 comments
Closed

[Bug]: AssertionError in UserDefinedType.__init__() #1783

webthethird opened this issue Mar 20, 2023 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@webthethird
Copy link
Contributor

Describe the issue:

I've got a fuzz testing contract that I generated using my differential fuzzing test generator, and it compiles, but I was getting an error when trying to test it with Echidna. So I ran slither --print echidna ./src/test/compound/DiffFuzzCustomInitialization.sol and saw the AssertionError below.

It appears to be asserting that None is either a Contract, Structure or Enum.

Code example to reproduce the issue:

https://github.com/webthethird/solidity-diff-fuzz-upgrades/blob/main/src/test/compound/DiffFuzzCustomInitialization.sol
https://github.com/webthethird/solidity-diff-fuzz-upgrades/blob/main/src/test/compound/DiffFuzzUpgrades.sol

Version:

0.9.2

Relevant log output:

Error in /home/webthethird/Ethereum/solidity-diff-fuzz-upgrades/src/test/compound/DiffFuzzCustomInitialization.sol
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/__main__.py", line 834, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/__main__.py", line 98, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/__main__.py", line 76, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/slither.py", line 133, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/slither.py", line 153, in _init_parsing_and_analyses
    raise e
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/slither.py", line 149, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/solc_parsing/slither_compilation_unit_solc.py", line 529, in analyze_contracts
    self._convert_to_slithir()
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/solc_parsing/slither_compilation_unit_solc.py", line 740, in _convert_to_slithir
    func.generate_slithir_and_analyze()
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/core/declarations/function.py", line 1750, in generate_slithir_and_analyze
    node.slithir_generation()
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/core/cfg/node.py", line 719, in slithir_generation
    self._irs = convert_expression(expression, self)
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/slithir/convert.py", line 119, in convert_expression
    result = apply_ir_heuristics(result, node)
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/slithir/convert.py", line 1858, in apply_ir_heuristics
    irs = propagate_type_and_convert_call(irs, node)
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/slithir/convert.py", line 442, in propagate_type_and_convert_call
    new_ins = propagate_types(ins, node)
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/slithir/convert.py", line 774, in propagate_types
    ir.lvalue.set_type(UserDefinedType(contract))
  File "/usr/local/lib/python3.10/dist-packages/slither_analyzer-0.9.2-py3.10.egg/slither/core/solidity_types/user_defined_type.py", line 19, in __init__
    assert isinstance(t, (Contract, Enum, Structure))
AssertionError
@0xalpharush
Copy link
Contributor

This is a duplicate of #1594 and related to this PR #1539

@webthethird
Copy link
Contributor Author

This is a duplicate of #1594 and related to this PR #1539

Ahh, didn't see that. Seems like PR #1539 is only blocked because of an old bug in the CI re pip-audit. If the CI checks were run again it'd probably pass. Anyway, either that or my fix in #1786 should probably be merged, right?

@0xalpharush 0xalpharush added bug Something isn't working duplicate This issue or pull request already exists and removed bug-candidate Bugs reports that are not yet confirmed labels Mar 22, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: AssertionError in UserDefinedType.__init__() [Bug]: AssertionError in UserDefinedType.__init__() Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants