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

[Lifter] NameError: name 'bv' is not defined #166

Closed mm4rks closed 1 year ago

mm4rks commented 1 year ago

What happened?

  File "/home/user/dewolf/decompile.py", line 80, in <module>
    main(Decompiler)
  File "/home/user/dewolf/decompiler/util/commandline.py", line 81, in main
    undecorated_code = decompiler.decompile_all(options)
  File "/home/user/dewolf/decompile.py", line 69, in decompile_all
    task = self._frontend.create_task(function, task_options)
  File "/home/user/dewolf/decompiler/frontend/binaryninja/frontend.py", line 67, in create_task
    raise e
  File "/home/user/dewolf/decompiler/frontend/binaryninja/frontend.py", line 60, in create_task
    cfg = self._extract_cfg(function, options)
  File "/home/user/dewolf/decompiler/frontend/binaryninja/frontend.py", line 92, in _extract_cfg
    return parser.parse(function)
  File "/home/user/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 "/home/user/dewolf/decompiler/frontend/binaryninja/parser.py", line 77, in _lift_instructions
    if lifted_instruction := self._lifter.lift(instruction):
  File "/home/user/dewolf/decompiler/frontend/binaryninja/lifter.py", line 28, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/home/user/dewolf/decompiler/frontend/binaryninja/handlers/assignments.py", line 51, in lift_assignment
    self._lifter.lift(assignment.src, parent=assignment),
  File "/home/user/dewolf/decompiler/frontend/binaryninja/lifter.py", line 28, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/home/user/dewolf/decompiler/frontend/binaryninja/handlers/unary.py", line 55, in lift_dereference_or_global_variable
    load_operand = self._lifter.lift(operation.src, parent=operation)
  File "/home/user/dewolf/decompiler/frontend/binaryninja/lifter.py", line 28, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/home/user/dewolf/decompiler/frontend/binaryninja/handlers/constants.py", line 70, in lift_constant_pointer
    return self._lifter.lift(variable, bv=bv, parent_addr=None)
  File "/home/user/dewolf/decompiler/frontend/binaryninja/lifter.py", line 28, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/home/user/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 38, in lift_global_variable
    initial_value = self._get_initial_value(bv, variable, addr, type_tokens)
  File "/home/user/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 77, in _get_initial_value
    return UnaryOperation(OperationType.address, [self.lift_global_variable(var2, bv=bv, parent_addr=addr)])
  File "/home/user/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 34, in lift_global_variable
    return self._lift_recursion_pointer(variable_name, vartype, addr)
  File "/home/user/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 60, in _lift_recursion_pointer
    vartype = Integer.uint64_t() if bv.address_size == 8 else Integer.uint32_t()
NameError: name 'bv' is not defined

How to reproduce?

python decompile.py dc4bb71234363d8f6eefc68f6dfd0f02596fff0ab514363691c03c35edbc1934 sub_3d40 --pipeline.debug

Affected Binary Ninja Version(s)

3.3.3996 (Build ID e34a955e)

NeoQuix commented 1 year ago

Fixed with #150

mm4rks commented 1 year ago

As of 7492e690 this bug remains.

NeoQuix commented 1 year ago

151 is not merged yet, but will fix the problem, sry thought it will be merged faster.

NeoQuix commented 1 year ago

Fixed with #150