fkie-cad / dewolf

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

[ValueError@binaryview.py:9122] ValueError: Couldn't find target for type #251

Closed mm4rks closed 1 year ago

mm4rks commented 1 year ago

What happened?

  File "/opt/dewolf/decompiler/util/bugfinder/bugfinder.py", line 164, in iter_function_reports
    task_result = self.decompile(function, options)
  File "/opt/dewolf/decompile.py", line 50, in decompile
    task = self._frontend.create_task(function, task_options)
  File "/opt/dewolf/decompiler/frontend/binaryninja/frontend.py", line 143, in create_task
    raise e
  File "/opt/dewolf/decompiler/frontend/binaryninja/frontend.py", line 130, in create_task
    cfg = self._extract_cfg(function.function, options)
  File "/opt/dewolf/decompiler/frontend/binaryninja/frontend.py", line 162, in _extract_cfg
    return parser.parse(function)
  File "/opt/dewolf/decompiler/frontend/binaryninja/parser.py", line 34, in parse
    index_to_BasicBlock[basic_block.index] = BasicBlock(basic_block.index, instructions=list(self._lift_instructions(basic_block)))
  File "/opt/dewolf/decompiler/frontend/binaryninja/parser.py", line 77, in _lift_instructions
    if lifted_instruction := self._lifter.lift(instruction):
  File "/opt/dewolf/decompiler/frontend/binaryninja/lifter.py", line 28, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/assignments.py", line 51, in lift_assignment
    self._lifter.lift(assignment.src, parent=assignment),
  File "/opt/dewolf/decompiler/frontend/binaryninja/lifter.py", line 28, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/constants.py", line 76, in lift_constant_pointer
    return self._lifter.lift(variable, view=view, parent=pointer)
  File "/opt/dewolf/decompiler/frontend/binaryninja/lifter.py", line 28, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 30, in lift_global_variable
    initial_value=self._get_initial_value(variable, view)
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 39, in _get_initial_value
    return self._lifter.lift(view.get_data_var_at(variable.value), view=view)
  File "/opt/dewolf/decompiler/frontend/binaryninja/lifter.py", line 28, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 30, in lift_global_variable
    initial_value=self._get_initial_value(variable, view)
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 41, in _get_initial_value
    return Constant(variable.value)
  File "/opt/binaryninja/python/binaryninja/binaryview.py", line 9229, in value
    return self._accessor.value
  File "/opt/binaryninja/python/binaryninja/binaryview.py", line 9082, in value
    return self._value_helper(self.type, self.view.read(self.address, len(self.type)))
  File "/opt/binaryninja/python/binaryninja/binaryview.py", line 9122, in _value_helper
    raise ValueError("Couldn't find target for type")

Error class ValueError@binaryview.py:9122 contains 1251 cases.

How to reproduce?

python decompile.py a776c4c370c289d13498c053dd7b1bfcbb342560d3fa60fff4b7d75feca45746 sub_3610 --debug

sample: a776c4c370c289d13498c053dd7b1bfcbb342560d3fa60fff4b7d75feca45746 dewolf commit: 5566666af0d3271618e758808fbc7be92be02e1d Binaryninja version: 3.4.4271

NeoQuix commented 1 year ago

Fixed with #233 Need to talk about NamedTypeReferences because I'm a bit confused

NeoQuix commented 1 year ago

Fixed temporary with unknown value + bninja upstream for 3.5