Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good tools for debugging VerifyError? [closed]

I find bytecode VerifyErrors notoriously hard to debug. The JVM gives very little feedback, typically just the current class and sometimes the method.

Some examples of errors I typically encounter when manually engineering bytecode through ASM or Jasmin:

  • Stack size too large
  • Unable to pop operand off an empty stack
  • Falling off the end of the code
  • Expecting to find object/array on stack
  • Incompatible object argument for function call
  • Inconsistent stack height 4 != 2

(To be clear; I know what all of these mean, I'm interested in tools or techniques to debug the cause of them.)

My Question: Is there any tool out there that gives detailed feedback on these types of errors? I would for instance appreciate information such as

  • javap-like output
  • references to line-numbers (or opcode byte offsets)
  • operand stack information (types / depth) on each line
  • more descriptive error messages
like image 402
aioobe Avatar asked Apr 02 '12 07:04

aioobe


2 Answers

I think you can use CheckClassAdapter(http://asm.ow2.org/asm40/javadoc/user/org/objectweb/asm/util/CheckClassAdapter.html) provided by ASM. It provide more detailed information about verify error.

like image 173
evasnowind Avatar answered Oct 04 '22 03:10

evasnowind


The Kraktau project I've written is useful for debugging verification errors. It is capable of giving the bytecode offsets where the error occurs, and the stack and local type information for every instruction. It even correctly handles flags and mask information for subroutines. It is capable of catching virtually all errors.

There isn't a specific interface for printing out verification information yet, but if you still me what kind of functionality you want, I can add one. In the meantime, attempting to decompile your class with Krakatau will print out an error message with information about the verification error and the type information of the instruction where it occurred.

Update: Krakatau no longer performs verification due to performance issues. If you want to do verfication, you'll need to checkout commit 3724c05ba11ff6913c01ecdfe4fde6a0f246e5db.

like image 29
Antimony Avatar answered Oct 04 '22 03:10

Antimony