Skip to content

Commit

Permalink
[ValueError@missing_definitions.py:218] Add check for duplicates in m…
Browse files Browse the repository at this point in the history
…issing definitions copy pool.(#330)

------

Co-authored-by: mm4rks <[email protected]>
Co-authored-by: Marvin Marks <[email protected]>
Co-authored-by: Marvin Marks <[email protected]>
Co-authored-by: Steffen Enders <[email protected]>
  • Loading branch information
5 people authored Sep 26, 2023
1 parent 455cecb commit def3a67
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions decompiler/pipeline/preprocessing/missing_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,19 @@ def get_smallest_label_copy(self, variable: Union[str, Variable]):
return self._sorted_copies_of[variable][0]
return min(self._copies_of_variable[variable], key=lambda var: var.ssa_label)

def _check_duplicated(self, var_name: str):
"""
Due to mixing of ssa_labels and memory versions, it can happen that we have duplicates in the copy pool.
E.g., [edx#0, edx#0, ...]
"""
ssa_labels = [var.ssa_label for var in self._sorted_copies_of[var_name]]
if any(i == j for i, j in zip(ssa_labels, ssa_labels[1:])):
raise ValueError(f"duplicate entries in copy pool for {var_name}")

def possible_missing_definitions_for(self, variable: Union[str, Variable]) -> List[Variable]:
"""Returns all variables whose definition may be missing because it is not the first in the order."""
var_name = self._get_variable_name(variable)
self._check_duplicated(var_name)
return self._sorted_copies_of[var_name][1:]

@staticmethod
Expand Down

0 comments on commit def3a67

Please sign in to comment.