Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Missing definitions] Every non-aliased variable should be defined, but variable has no definition. #215

Open
NeoQuix opened this issue Apr 6, 2023 · 4 comments
Assignees
Labels
blocked Is blocked by another issue bug Something isn't working priority-high High priority issue upstream

Comments

@NeoQuix
Copy link
Collaborator

NeoQuix commented Apr 6, 2023

What happened?

Error in bin/sacsess.exe in 0x140003750
[pipeline.py:107 run()] ERROR - Failed to decompile ?Write@CVTUTF8Scraper@@UEAAHXZ, error during stage insert-missing-definitions: Every non-aliased variable should be defined, but variable rdx_2#4 has no definition.
Traceback (most recent call last):
  File "/home/neoquix/Git-Repos/DeWolf/decompile.py", line 76, in <module>
    main(Decompiler)
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/util/commandline.py", line 80, in main
    task = decompiler.decompile(function_name, options)
  File "/home/neoquix/Git-Repos/DeWolf/decompile.py", line 51, in decompile
    pipeline.run(task)
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/pipeline/pipeline.py", line 109, in run
    raise e
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/pipeline/pipeline.py", line 102, in run
    instance.run(task)
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/pipeline/preprocessing/missing_definitions.py", line 99, in run
    self.insert_missing_definitions()
  File "/home/neoquix/Git-Repos/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/neoquix/Git-Repos/DeWolf/decompiler/pipeline/preprocessing/missing_definitions.py", line 157, in _insert_definition_if_undefined
    raise ValueError(f"Every non-aliased variable should be defined, but variable {variable} has no definition.")
ValueError: Every non-aliased variable should be defined, but variable rdx_2#4 has no definition.

How to reproduce?

Decompile sacsess at 0x140003750.

Affected Binary Ninja Version(s)

3.3.3996

@NeoQuix NeoQuix added bug Something isn't working priority-high High priority issue labels Apr 6, 2023
@ebehner
Copy link
Collaborator

ebehner commented Apr 27, 2023

The problem is that the phi-function for variable rdx_2#4 is missing. Having a look at the program in MLIL, one can see that rdx_2 is defined twice, and two different definitions can reach the usage in the "last" block:
issue_215_non_ssa

Now, in MLIL SSA-form, Binary Ninja assign different SSA-labels for the two definitions and another one for the usage. However, the phi-function at the beginning of the block is missing. There is only the phi-function for rdx_3#4 = phi(rdx_2#2, rdx_2#3), but there should also be the phi-function rdx_2#4 = phi(rdx_2#2, rdx_2#3):
issue_215_ssa_form

We have two options:

  1. We say it is a Binary Ninja problem and ignore it or write an Issue
  2. We update the missing definitions algorithm and introduce such phi-functions by our own.

@ebehner
Copy link
Collaborator

ebehner commented Apr 27, 2023

preferable, binary ninja issue
block issue until fixed by binary ninja, if they will not do it, we will try to solve it by our own.

@NeoQuix
Copy link
Collaborator Author

NeoQuix commented Apr 27, 2023

Will block for now and create a bninja issue later.

@NeoQuix NeoQuix added the blocked Is blocked by another issue label Apr 27, 2023
@NeoQuix
Copy link
Collaborator Author

NeoQuix commented Aug 4, 2023

Upstream: Vector35/binaryninja-api#4546

@NeoQuix NeoQuix self-assigned this Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Is blocked by another issue bug Something isn't working priority-high High priority issue upstream
Projects
None yet
Development

No branches or pull requests

2 participants