[Soot-list] Question regarding Java Bytecode

Eric Bodden eric.bodden at ec-spride.de
Fri Dec 2 04:38:39 EST 2011


Hi Bernhard.

Yes, to me this clearly looks like invalid bytecode. By the way,
usually you can easily find out whether bytecode is valid by just
passing the respective class to the "java" command. Even if the type
has no main method, the VM will invoke the bytecode verifier on it and
complain if the code is invalid.

Eric

2011/12/2 Bernhard Berger <berber at tzi.de>:
> Hi everybody,
>
> today soot greeted me with a nice exception located somewhere deep in
> the coffie-source. Since the bytecode I am analyzing is not generated by
> a default java compiler the Bytecode might be the culprit. The stack
> trace is the following one:
>
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6
>  at soot.coffi.ByteCode.locateInstr(ByteCode.java:1104)
>  at soot.coffi.ByteCode.locateInstr(ByteCode.java:1108)
>  at soot.coffi.ByteCode.locateInstr(ByteCode.java:1108)
>  at soot.coffi.ByteCode.locateInst(ByteCode.java:1097)
>  at soot.coffi.ClassFile.parseMethod(ClassFile.java:1248)
>  at soot.coffi.CoffiMethodSource.getBody(CoffiMethodSource.java:78)
>  at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:82)
>  at soot.SootMethod.retrieveActiveBody(SootMethod.java:315)
>  at soot.PackManager.retrieveAllBodies(PackManager.java:989)
>  at soot.PackManager.runPacks(PackManager.java:338)
>  at soot.Main.run(Main.java:198)
>  at soot.Main.main(Main.java:141)
>
> I took a look at the method's Bytecode and its exception table sind soot
> handles links exception table to the corresponding Bytecode instructions
> at this point. I think the Bytecode is not correct at this point but I'm
> not a Bytecode expert. Perhaps someone can support my theory.
>
> javap gives me the following output for the method in question:
>
> public java.lang.String getPluginsPath();
>  Code:
>   0:   aload_0
>   1:   monitorenter
>   2:   aload_0
>   3:   monitorexit
>   4:   ldc     #209; //String
>   6:   areturn
>  Exception table:
>   from   to  target type
>     2     2     7   any
>
> I consulted the JVM-spec and it states for the exception table:
> The value of the handler_pc (target in this case) item indicates the
> start of the exception handler. The value of the item must be a valid
> index into the code array and must be the index of the opcode of an
> instruction.
>
> Therefore the Bytecode is not corret, since the handler_pc does not
> point to a valid address. Am I correct? If the Bytecode is invalid I am
> going to blame the author of the tool that generated the Bytecode. :-)
>
> Regards from Bremen, Germany
>
> Bernhard
>
> _______________________________________________
> 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
Principal Investigator in Secure Services at CASED
Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
Room 3.2.14, Mornewegstr. 32, 64293 Darmstadt


More information about the Soot-list mailing list