Need `BNGetLiftedlILBasicBlockForInstruction` to ensure `il_basic_block` will return successfully on lifted_il APIs

Aperta
#1,320 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
cpp, python

Direzione di ricerca

Reproduce the failure with the lifted_il loop from the issue, then inspect python/binaryninja/lowlevelil.py around il_basic_block and LowLevelILBasicBlock, along with the BNGetLiftedILBasicBlockForInstruction entry point. Compare its behavior with the working llil and mlil cases; done means the lifted_il loop returns a valid il_basic_block without the constructor or cleanup exceptions.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Component: Core Impact: Low

On any sufficiently large binary, /bin/ls for example, the following code will not complete without generating an exception.

for func in bv.functions:
  for bb in func.lifted_il:
    for inst in bb:
      inst.il_basic_block

When replacing func.lifted_il with either func.llil or func.mlil, it seems to work fine.

The exception generated is:

Exception AttributeError: "'LowLevelILBasicBlock' object has no attribute 'handle'" in <object repr() failed> ignored
Traceback (most recent call last):
  File "<console>", line 4, in <module>
  File "/home/kyle/binaryninja/plugins/../python/binaryninja/lowlevelil.py", line 537, in il_basic_block
    return LowLevelILBasicBlock(view, core.BNGetLowLevelILBasicBlockForInstruction(self.function.handle, self.instr_index), self.function)
  File "/home/kyle/binaryninja/plugins/../python/binaryninja/lowlevelil.py", line 2413, in __init__
    super(LowLevelILBasicBlock, self).__init__(handle, view)
  File "/home/kyle/binaryninja/plugins/../python/binaryninja/basicblock.py", line 62, in __init__
    self.handle = core.handle_of_type(handle, core.BNBasicBlock)
  File "/home/kyle/binaryninja/plugins/../python/binaryninja/_binaryninjacore.py", line 13434, in handle_of_type
    raise ValueError('expected pointer to %s' % str(handle_type))
ValueError: expected pointer to <class 'binaryninja._binaryninjacore.BNBasicBlock'>

Later, when closing ipython or waiting an arbitrary amount of time, the following exception is generated:

Exception ignored in: <object repr() failed>
Traceback (most recent call last):
  File "/home/kyle/binaryninja/python/binaryninja/basicblock.py", line 69, in __del__
AttributeError: 'LowLevelILBasicBlock' object has no attribute 'handle'

Nearly identical blocks/instructions are affected, does seem to break consistently on the same block in the same binary, but I I think that's more happenstance than anything.

Present in both Python2 and Python3, sorta seems like a dangling pointer issue to me.

Lingua principale
C++
Stelle
1.3k
Fork
298
Merge medio
5g 5h
PR unite (30g)
19

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Vector35/binaryninja-api

Tutte le issue di Vector35/binaryninja-api

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.