binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

_high_level_il_instruction_is_valid being called with an old instruction index if function body is changed

Open mostobriv opened this issue 2 months ago • 0 comments

Version and Platform (required):

  • Binary Ninja Version: 5.3.8699-dev Personal (42cbde5c) (but I've met this bug year ago at least)
  • Edition: Non-Commercial

Bug Description: If you select the token in function and then do something, that makes this token to disappear (for example changing switch-table, thus the functions cfg is shrinking), then when _high_level_il_instruction_is_valid is called, it looks like to use old instruction index on the new IL object, thus there is IndexError is thrown.

Steps To Reproduce: Please provide all steps required to reproduce the behavior:

  1. Register plugin for high_level_il_instruction
  2. Select token in HLIL
  3. Do something to function, so the token is disappear
  4. Viola, you've got an exception

Expected Behavior: No exceptions is thrown (logged).

Screenshots/Video Recording: Image

Additional Information: Sample plugin i've tested it on:

from binaryninja import BinaryView, HighLevelILInstruction, PluginCommand


def my_plugin(bv: BinaryView, inst: HighLevelILInstruction):
    return


def is_valid(bv: BinaryView, inst: HighLevelILInstruction) -> bool:
    return False


PluginCommand.register_for_high_level_il_instruction(
    "plugin name", "plugin desc", my_plugin, is_valid
)

mostobriv avatar Nov 30 '25 09:11 mostobriv