crytic / slither

Static Analyzer for Solidity and Vyper
https://blog.trailofbits.com/2018/10/19/slither-a-solidity-static-analysis-framework/
GNU Affero General Public License v3.0
5.33k stars 967 forks source link

[Bug-Candidate]: Failed to convert IR to SSA for Initializable contract. #2552

Closed RegisGraptin closed 1 month ago

RegisGraptin commented 1 month ago

Describe the issue:

I am running slither . on my project and run into the following issue (see logs section). Do not hesitate to tell me if I can provide additional information.

Code example to reproduce the issue:

Cannot share it at the moment. Will need to investigate which contract causes the issue and obfuscate some parts.

Version:

0.10.4

Relevant log output:

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 "/.../.pyenv/versions/3.12.4/bin/slither", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/__main__.py", line 776, in main
    main_impl(all_detector_classes=detectors, all_printer_classes=printers)
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/__main__.py", line 882, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/__main__.py", line 107, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/__main__.py", line 80, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/slither.py", line 202, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/slither.py", line 221, in _init_parsing_and_analyses
    raise e
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/slither.py", line 217, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 593, in analyze_contracts
    self._convert_to_slithir()
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 834, in _convert_to_slithir
    raise e
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 829, in _convert_to_slithir
    contract.convert_expression_to_slithir_ssa()
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/core/declarations/contract.py", line 1577, in convert_expression_to_slithir_ssa
    func.generate_slithir_ssa(all_ssa_state_variables_instances)
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/core/declarations/function_contract.py", line 140, in generate_slithir_ssa
    add_ssa_ir(self, all_ssa_state_variables_instances)
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/slithir/utils/ssa.py", line 206, in add_ssa_ir
    fix_phi_rvalues_and_storage_ref(
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/slithir/utils/ssa.py", line 526, in fix_phi_rvalues_and_storage_ref
    fix_phi_rvalues_and_storage_ref(
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/slithir/utils/ssa.py", line 526, in fix_phi_rvalues_and_storage_ref
    fix_phi_rvalues_and_storage_ref(
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/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 "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/slithir/utils/ssa.py", line 497, in fix_phi_rvalues_and_storage_ref
    last_name(dst, ir.lvalue, init_local_variables_instances) for dst in ir.nodes
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.pyenv/versions/3.12.4/lib/python3.12/site-packages/slither/slithir/utils/ssa.py", line 363, in last_name
    assert candidates
           ^^^^^^^^^^
AssertionError
smonicas commented 1 month ago

Likely duplicate of https://github.com/crytic/slither/issues/2491, try the same workaround mentioned there. TLDR add --skip-assembly when running slither.

RegisGraptin commented 1 month ago

@smonicas Thanks the --skip-assembly seems to unlock the situation. Should have try to looked at similar issue first before posting it :sweat_smile:

smonicas commented 1 month ago

Closing this as it's a duplicate