fkie-cad / dewolf

A research decompiler implemented as a Binary Ninja plugin.
GNU Lesser General Public License v2.1
171 stars 9 forks source link

ValueError: Memory version 2 does not exist in missing_definitions #133

Closed jnhols closed 1 year ago

jnhols commented 1 year ago

What happened?

The decompiler crashes with a ValueError in missing_definitions during preprocessing.

Traceback (most recent call last):
    File ""/home/ubuntu/.binaryninja/plugins/dewolf/decompile.py"", line 80, in <module>
main(Decompiler)
    File ""/home/ubuntu/.binaryninja/plugins/dewolf/decompiler/util/commandline.py"", line 65, in main
task = decompiler.decompile(function_name, options)
    File ""/home/ubuntu/.binaryninja/plugins/dewolf/decompile.py"", line 55, in decompile
pipeline.run(task)
    File ""/home/ubuntu/.binaryninja/plugins/dewolf/decompiler/pipeline/pipeline.py"", line 97, in run
instance.run(task)
    File ""/home/ubuntu/.binaryninja/plugins/dewolf/decompiler/pipeline/preprocessing/missing_definitions.py"", line 99, in run
self.insert_missing_definitions()
    File ""/home/ubuntu/.binaryninja/plugins/dewolf/decompiler/pipeline/preprocessing/missing_definitions.py"", line 133, in insert_missing_definitions
self._insert_definition_if_undefined(variable, previous_ssa_labels, undefined_variables)
    File ""/home/ubuntu/.binaryninja/plugins/dewolf/decompiler/pipeline/preprocessing/missing_definitions.py"", line 158, in _insert_definition_if_undefined
self._insert_definition_of_aliased(variable, previous_ssa_labels)
    File ""/home/ubuntu/.binaryninja/plugins/dewolf/decompiler/pipeline/preprocessing/missing_definitions.py"", line 173, in _insert_definition_of_aliased
self._check_definition_is_insertable(variable)
    File ""/home/ubuntu/.binaryninja/plugins/dewolf/decompiler/pipeline/preprocessing/missing_definitions.py"", line 286, in _check_definition_is_insertable
raise ValueError(error_message)
ValueError: Memory version 2 does not exist. So we can not insert the definition of the aliased variable input_position#2.

How to reproduce?

Decompile read_line in the following sample.

pr.zip

Affected Binary Ninja Version(s)

3.2.3814

NeoQuix commented 1 year ago

/cib

github-actions[bot] commented 1 year ago

Branch issue-133-ValueError_Memory_version_2_does_not_exist_in_missing_definitions created!

NeoQuix commented 1 year ago

Lifter does not lift the correct memory_ssa from a MLIL_STORE_STRUCT_SSA instruction. Therefore the missing definitions stage fails.

Setting the variable writes_memory to the dest_memory ssa_label fixes the problem.