Good tools for debugging VerifyError? [closed]
Asked Answered
P

2

11

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
Palladio answered 2/4, 2012 at 7:31 Comment(2)
https://mcmap.net/q/1158769/-java-lang-verifyerror will it help?Peres
publib.boulder.ibm.com/infocenter/iseries/v5r3/… did it help?Peres
C
3

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.

Cowley answered 25/7, 2013 at 5:51 Comment(0)
S
3

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.

Scholasticate answered 12/10, 2012 at 2:24 Comment(0)
C
3

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.

Cowley answered 25/7, 2013 at 5:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.