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]: ERROR:root:Top level EventDefinition not supported #2445

Closed
SquilliamX opened this issue Apr 25, 2024 · 5 comments
Closed

[Bug]: ERROR:root:Top level EventDefinition not supported #2445

SquilliamX opened this issue Apr 25, 2024 · 5 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@SquilliamX
Copy link

SquilliamX commented Apr 25, 2024

Describe the issue:

When I run slither . in this repo, it returns:

'forge clean' running (wd: /home/smartchain/code/audits/broken/slither-breaks/wallflower-contract-v2)
'forge build --build-info --skip */test/** */script/** --force' running (wd: /home/smartchain/code/audits/broken/slither-breaks/wallflower-contract-v2)
Traceback (most recent call last):
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/__main__.py", line 833, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/__main__.py", line 107, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/__main__.py", line 80, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slither.py", line 118, in __init__
    sol_parser.parse_top_level_items(ast, path)
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 351, in parse_top_level_items
    raise SlitherException(f"Top level {top_level_data[self.get_key()]} not supported")
slither.exceptions.SlitherException: Top level EventDefinition not supported
ERROR:root:Error:
ERROR:root:Top level EventDefinition not supported
ERROR:root:Please report an issue to https://github.com/crytic/slither/issues
image

UPDATE: I upgraded to 0.10.1 using python3 -m pip install slither-analyzer -U but now I recieve this error:

`$ slither .
'forge clean' running (wd: /home/smartchain/code/audits/broken/slither-breaks/wallflower-contract-v2)
'forge config --json' running
'forge build --build-info --skip /test/* /script/* --force' running (wd: /home/smartchain/code/audits/broken/slither-breaks/wallflower-contract-v2)
ERROR:SlitherSolcParsing:
Failed to convert IR to SSA for Initializable contract. Please open an issue https://github.com/crytic/slither/issues.

Traceback (most recent call last):
File "/home/smartchain/.local/bin/slither", line 8, in
sys.exit(main())
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/main.py", line 753, in main
main_impl(all_detector_classes=detectors, all_printer_classes=printers)
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/main.py", line 859, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/main.py", line 107, in process_all
) = process_single(compilation, args, detector_classes, printer_classes)
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/main.py", line 80, in process_single
slither = Slither(target, ast_format=ast, **vars(args))
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slither.py", line 199, in init
self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slither.py", line 219, in _init_parsing_and_analyses
raise e
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slither.py", line 215, in _init_parsing_and_analyses
parser.analyze_contracts()
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 593, in analyze_contracts
self._convert_to_slithir()
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 834, in _convert_to_slithir
raise e
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 829, in _convert_to_slithir
contract.convert_expression_to_slithir_ssa()
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/core/declarations/contract.py", line 1579, in convert_expression_to_slithir_ssa
func.generate_slithir_ssa(all_ssa_state_variables_instances)
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/core/declarations/function_contract.py", line 140, in generate_slithir_ssa
add_ssa_ir(self, all_ssa_state_variables_instances)
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 206, in add_ssa_ir
fix_phi_rvalues_and_storage_ref(
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 526, in fix_phi_rvalues_and_storage_ref
fix_phi_rvalues_and_storage_ref(
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 526, in fix_phi_rvalues_and_storage_ref
fix_phi_rvalues_and_storage_ref(
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 526, in fix_phi_rvalues_and_storage_ref
fix_phi_rvalues_and_storage_ref(
[Previous line repeated 4 more times]
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 496, in fix_phi_rvalues_and_storage_ref
variables = [
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 497, in
last_name(dst, ir.lvalue, init_local_variables_instances) for dst in ir.nodes
File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 363, in last_name
assert candidates
AssertionError`

image

Code example to reproduce the issue:

this is the repo that makes slither throw an error:

https://github.com/SquilliamX/repo-breaks-slither

Version:

0.10.0

@SquilliamX SquilliamX added the bug-candidate Bugs reports that are not yet confirmed label Apr 25, 2024
@0xalpharush
Copy link
Member

@SquilliamX Please upgrade (python3 -m pip install slither-analyzer -U) as support was added in 0.10.1 #2219

@SquilliamX
Copy link
Author

hello @0xalpharush , I did what you said and upgraded using the command python3 -m pip install slither-analyzer -U , but am now receiving this error:

'forge clean' running (wd: /home/smartchain/code/audits/broken/slither-breaks/wallflower-contract-v2)
'forge config --json' running
'forge build --build-info --skip */test/** */script/** --force' running (wd: /home/smartchain/code/audits/broken/slither-breaks/wallflower-contract-v2)
ERROR:SlitherSolcParsing:
Failed to convert IR to SSA for Initializable contract. Please open an issue https://github.com/crytic/slither/issues.
 
Traceback (most recent call last):
  File "/home/smartchain/.local/bin/slither", line 8, in <module>
    sys.exit(main())
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/__main__.py", line 753, in main
    main_impl(all_detector_classes=detectors, all_printer_classes=printers)
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/__main__.py", line 859, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/__main__.py", line 107, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/__main__.py", line 80, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slither.py", line 199, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slither.py", line 219, in _init_parsing_and_analyses
    raise e
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slither.py", line 215, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 593, in analyze_contracts
    self._convert_to_slithir()
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 834, in _convert_to_slithir
    raise e
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 829, in _convert_to_slithir
    contract.convert_expression_to_slithir_ssa()
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/core/declarations/contract.py", line 1579, in convert_expression_to_slithir_ssa
    func.generate_slithir_ssa(all_ssa_state_variables_instances)
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/core/declarations/function_contract.py", line 140, in generate_slithir_ssa
    add_ssa_ir(self, all_ssa_state_variables_instances)
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 206, in add_ssa_ir
    fix_phi_rvalues_and_storage_ref(
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 526, in fix_phi_rvalues_and_storage_ref
    fix_phi_rvalues_and_storage_ref(
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 526, in fix_phi_rvalues_and_storage_ref
    fix_phi_rvalues_and_storage_ref(
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 526, in fix_phi_rvalues_and_storage_ref
    fix_phi_rvalues_and_storage_ref(
  [Previous line repeated 4 more times]
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 496, in fix_phi_rvalues_and_storage_ref
    variables = [
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 497, in <listcomp>
    last_name(dst, ir.lvalue, init_local_variables_instances) for dst in ir.nodes
  File "/home/smartchain/.local/lib/python3.10/site-packages/slither/slithir/utils/ssa.py", line 363, in last_name
    assert candidates
AssertionError

@0xalpharush
Copy link
Member

This looks like the same bug as #2160. Thanks for the thorough bug report and uploading a repo for us to triage with

Maybe related to the use of LibZip. You can try what I recommend there as a workaround: add --skip-assembly to command

@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Apr 25, 2024
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: ERROR:root:Top level EventDefinition not supported [Bug]: ERROR:root:Top level EventDefinition not supported Apr 25, 2024
@SquilliamX
Copy link
Author

This looks like the same bug as #2160. Thanks for the thorough bug report and uploading a repo for us to triage with

Maybe related to the use of LibZip. You can try what I recommend there as a workaround: add --skip-assembly to command

thanks, this is a great work around! And I am happy to upload the repo to help solve bugs and make our tools better!

@0xalpharush 0xalpharush added the duplicate This issue or pull request already exists label Apr 30, 2024
@0xalpharush
Copy link
Member

Will track in #2160

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