Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
849 stars 194 forks source link

mlil_functions() iteration throws exception if 'analysis skipped' functions are present #3157

Closed SensorLock closed 2 years ago

SensorLock commented 2 years ago

Version and Platform (required):

Bug Description: Iterating over mlil_functions breaks if there is a function skipped by analysis. Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\Users\\AppData\Local\Vector35\BinaryNinja\plugins\..\python\binaryninja\binaryview.py", line 2261, in mlil_functions yield func.mlil File "C:\Users\\AppData\Local\Vector35\BinaryNinja\plugins\..\python\binaryninja\function.py", line 885, in mlil return mediumlevelil.MediumLevelILFunction(self.arch, core.BNGetFunctionMediumLevelIL(self.handle), self) File "C:\Users\\AppData\Local\Vector35\BinaryNinja\plugins\..\python\binaryninja\mediumlevelil.py", line 2663, in __init__ _handle = core.BNCreateMediumLevelILFunction(self.arch.handle, func_handle) File "C:\Users\\AppData\Local\Vector35\BinaryNinja\plugins\..\python\binaryninja\mediumlevelil.py", line 3081, in arch return self._arch AttributeError: 'MediumLevelILFunction' object has no attribute '_arch'

Steps To Reproduce:

  1. Set analysis.limits.maxFunctionAnalysisTime to a very low value (I used 10ms)
  2. Load a binary
  3. Execute list(bv.mlil_functions()) in the console

Expected Behavior: I believe past versions returned a dummy MLIL function object in this case. That had the correct source_function attr, and that source_function object had skipped = True.

Additional There is a path to this same bug through bv.get_callers() as well, when you try to access .mlils off a function in that iteration.

D0ntPanic commented 2 years ago

Fixed in build 3481