[Soot-list] java.lang.VerifyError

Bruno Dufour dufour at iro.umontreal.ca
Fri Sep 7 10:39:07 EDT 2012


On 2012-09-07, at 3:58 AM, Eric Bodden <eric.bodden at ec-spride.de> wrote:

> Ok, so this should tell you that you are invoking some instruction that consumes an object/array off the stack (probably an instance method call) although the stack is empty or has some primitive value on the top.

Exactly, if I look at the first few bytecode instructions for the main method (as produced by javap):

public static void main(java.lang.String[]);
  Code:
   0:	bipush	9
   2:	dup
   3:	iconst_3
   4:	istore_0
   5:	invokestatic	#13; //Method DynamicAnalysisUsedTracer.appendConExpr:(Ljava/lang/Object;)V
   ... (more code) ...

At the time of the call to appendConExpr, you stack contains two integers ([9,9]) (due to bipush 9; dup). So, you're trying to call appendConExpr(9) when in fact it expects an object. Note that there is no autoboxing of primitives performed in bytecode, it is only syntactic sugar that is replaced during compilation.

Looking back at the soot instrumentation code that was provided, it seems that this expression, used as argument for the call, is at fault :

((BinopExpr) ((IfStmt) stmt).getCondition()).getOp1()

Intuitively, the operands of a binary expression are not objects, so this instrumentation will always fail verification.

Hope this helps,

Bruno

> 
> Eric
> 
> On 7 September 2012 08:19, 左小强 <xiaoqiang861025 at yahoo.cn> wrote:
> Hi Eric,
> Exception information is as follows:
> 
> Exception in thread "main" java.lang.VerifyError: (class: test, method: main sig
> nature: ([Ljava/lang/String;)V) Expecting to find object/array on stack
>         at java.lang.Class.getDeclaredMethods0(Native Method)
>         at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
>         at java.lang.Class.getMethod0(Unknown Source)
>         at java.lang.Class.getMethod(Unknown Source)
>         at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
>         at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
> 
> 
> 
> --- 12年9月6日,周四, Eric Bodden <eric.bodden at ec-spride.de> 写道:
> 
> 发件人: Eric Bodden <eric.bodden at ec-spride.de>
> 
> 主题: Re: [Soot-list] java.lang.VerifyError
> 收件人: "左小强" <xiaoqiang861025 at yahoo.cn>
> 抄送: "Richard Xiao" <richardxx at cse.ust.hk>, "soot" <soot-list at sable.mcgill.ca>
> 日期: 2012年9月6日,周四,下午10:38
> 
> 
> Hello.
> 
> Do you just get "VerifyError" or does the VM print some additional information? Usually you get some additional info that can help debug the problem (or not).
> 
> Eric
> 
> On 6 September 2012 09:31, 左小强 <xiaoqiang861025 at yahoo.cn> wrote:
> Hi Richard,
> 
> Thanks for your reply. But I can't understand what you mean. Can you explain your point further?
> 
> Actually I think the problem is that here I use java.lang.Object as the parameter type. I doubt whether it's not compitable with the Jimple Value type.
> 
> anyway, thank you.
> 
> 
> Zhiqiang
> 
> --- 12年9月5日,周三, Richard Xiao <richardxx at cse.ust.hk> 写道:
> 
> 发件人: Richard Xiao <richardxx at cse.ust.hk>
> 主题: Re: [Soot-list] java.lang.VerifyError
> 收件人: "左小强" <xiaoqiang861025 at yahoo.cn>
> 抄送: "soot" <soot-list at sable.mcgill.ca>
> 日期: 2012年9月5日,周三,下午2:13
> 
> 
> Your insertion violates some Java specifications. For example, in a constructor function, the call the super constructor must be the first statement. However, you place your instrumentation at the first position, hence it invalidates the verifier.
> 
> best,
> richardxx
> 
> 
> On Wed, Sep 5, 2012 at 1:11 PM, 左小强 <xiaoqiang861025 at yahoo.cn> wrote:
> Hi all,
> 
> I tried to obtain the runtime value of the operand in ConditionExpr (IfStmt). Therefore I use Soot to instrument the class file.
> 
> I intend to insert the following function into the class file:
> 
>    public static void appendConExpr(java.lang.Object op1)
> 
> using the following statements:
> 
>    InvokeExpr conditionExpr = Jimple.v().newStaticInvokeExpr(
> 			traceAppendConExpr.makeRef(), 
>                         ((BinopExpr) ((IfStmt) stmt).getCondition()).getOp1());
>   Stmt conditionStmt = Jimple.v().newInvokeStmt(conditionExpr);
>   units.insertBefore(conditionStmt, stmt);
> 
> The instrumentation phase is OK, however when i run the instrumented program, the Exception "java.lang.VerifyError" is thrown.
> 
> Can anyone tell me the reason and how to fix it? Thanks in advance!
> 
> 
> Zhiqiang
>    
> 
> 
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> 
> 
> 
> 
> -- 
> Richard Xiao Xiao
> PhD Student @ CSE @ Hong Kong University of Science and Technology
> www.cse.ust.hk/~richardxx
> 
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> 
> 
> 
> 
> -- 
> Eric Bodden, Ph.D., http://bodden.de/
> Head of Secure Software Engineering Group at EC SPRIDE
> Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
> Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
> 
> 
> 
> -- 
> Eric Bodden, Ph.D., http://bodden.de/
> Head of Secure Software Engineering Group at EC SPRIDE
> Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
> Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list



More information about the Soot-list mailing list