FuzzingLabs / thoth

Cairo/Starknet security toolkit (bytecode analyzer, disassembler, decompiler, symbolic execution, SBMC)
https://fuzzinglabs.com/
GNU Affero General Public License v3.0
247 stars 21 forks source link

fails with casm for 2.1.0 compiler with `IndexError: list index out of range` #139

Open moodysalem opened 1 year ago

moodysalem commented 1 year ago

with casm output file from latest scarb 0.6.0-alpha.4, it prints ~300 lines like this

image

and then this stack trace

Traceback (most recent call last):
  File "/home/runner/.local/bin/thoth", line 8, in <module>
    sys.exit(main())
  File "/home/runner/.local/lib/python3.10/site-packages/thoth/thoth.py", line 213, in main
    if a._detect():
  File "/home/runner/.local/lib/python3.10/site-packages/thoth/app/analyzer/testing/tests_cases_generator.py", line 34, in _detect
    decompiler.decompile_code(first_pass_only=True)
  File "/home/runner/.local/lib/python3.10/site-packages/thoth/app/decompiler/decompiler.py", line 193, in decompile_code
    self.print_build_code(
  File "/home/runner/.local/lib/python3.10/site-packages/thoth/app/decompiler/decompiler.py", line 91, in print_build_code
    source_code += self._handle_assert_eq_decomp(instruction)
  File "/home/runner/.local/lib/python3.10/site-packages/thoth/app/decompiler/_instruction_handlers.py", line 211, in _handle_assert_eq_decomp
    if self.ssa.get_variable(op0_register, offset_1)[2] in phi_node_variables:
  File "/home/runner/.local/lib/python3.10/site-packages/thoth/app/decompiler/ssa.py", line 96, in get_variable
    name = self.memory[position].name
IndexError: list index out of range