Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.VerifyError errors using Java ASM

I am trying to write an instrumentation module for Java programs. One particular instrumentation I am looking to add is collecting all the objects in a method's argument list and do some processing on them.

Currently, to get the list of object arguments, I pop all the method args from stack, and then push them in one by one, adding my instrumentation call in between. While this mostly works, I see some

java.lang.VerifyError, [1] (****) Incompatible argument to function

type errors in large programs. Does popping and then pushing an object back to stack change its type somehow? Alternatively, is there a better solution for duplicating 'N' arguments from the stack without popping?

like image 628
arunxls Avatar asked Feb 25 '26 22:02

arunxls


1 Answers

Where are you popping your arguments to? You need to store them in the local variable array, I assume? It is perfectly possible that you override variables that are stored there already but which are accessed later. In this case, you might have changed the types of the stored variables which yields an error during verification.

As verification is a determinisitic process: Simply compare the byte code of a failing method to the verifiers complaint and make sure that the types match.

like image 120
Rafael Winterhalter Avatar answered Feb 27 '26 16:02

Rafael Winterhalter