herast icon indicating copy to clipboard operation
herast copied to clipboard

Removing instruction lead to ida internal error

Open yoavst opened this issue 9 months ago • 0 comments

IDA 9.0

Given the following example:

from __future__ import annotations
from herapi import *

test_pattern = CallInsnPat(HelperPat('objc_release'), ignore_arguments=True)


class ItemRemovalScheme(Scheme):
	def on_matched_item(self, item, ctx: MatchContext) -> ASTPatch|None:
		return ASTPatch.remove_instr(item)


register_storage_scheme("remove_objc_release", ItemRemovalScheme(test_pattern))

Running it on a function with v12 = objc_retain(a6) leads to:

1000494A8: INTERR 50067
Unknown exception
Exception in ida_hexrays.Hexrays_Hooks dispatcher function: SWIG director method error. Error detected when calling 'Hexrays_Hooks.maturity'
Traceback (most recent call last):
  File "/Applications/IDA Professional 9.0.app/Contents/MacOS/python/ida_hexrays.py", line 27990, in maturity
    def maturity(self, *args): return self.callback(hxe_maturity, *args)
                                      ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "herast.py", line 72, in herast_callback
    raise e
  File "herast.py", line 68, in herast_callback
    matcher.match_cfunc(cfunc)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "herast/tree/matcher.py", line 58, in match_cfunc
    self.match_ast_tree(ast_tree, ast_ctx, schemes)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "herast/tree/matcher.py", line 77, in match_ast_tree
    if not ast_proc.apply_patch(ast_patch, ast_ctx):
           ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "herast/tree/ast_processor.py", line 159, in apply_patch
    relpos = self.get_relative_position(item_path, ast_ctx)
  File "herast/tree/ast_processor.py", line 105, in get_relative_position
    if item == self.get_current():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/IDA Professional 9.0.app/Contents/MacOS/python/ida_hexrays.py", line 20968, in __eq__
    return _ida_hexrays.cinsn_t___eq__(self, r)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
RuntimeError: Unknown exception

yoavst avatar Mar 25 '25 16:03 yoavst