Skip to content

VerifyError: Bad type on operand stack #644

@magicwerk

Description

@magicwerk

I was playing with the HistoOnEvent example and modified it slightly as shown below.
If I specify another class, e.g. EqualsBuilder, it fails with a VerifyError.
I can make it run without VerifyError, if I comment out the line with "incrementAndGet()" (but then the logic is broken).

Trace:

@BTrace
public class HistoOnEvent {

	private static Map<String, AtomicInteger> histo = newHashMap();

	// WORKS
	//@OnMethod(clazz = "javax.swing.JComponent", method = "<init>")
	// FAILS
	@OnMethod(clazz = "org.apache.commons.lang3.builder.EqualsBuilder", method = "<init>")
	public static void onMethod(@Self Object obj) {
		String cn = name(classOf(obj));
		AtomicInteger ai = get(histo, cn);
		if (ai == null) {
			ai = newAtomicInteger(1);
			put(histo, cn, ai);
		} else {
			incrementAndGet(ai);	// WORKS if commented out
		}
	}

	@OnTimer(1000)
	public static void print() {
		printNumberMap("Component Histogram", histo);
	}
}

Output:

Exception in thread "Thread-6" Exception in thread "Thread-7" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/apache/commons/lang3/builder/EqualsBuilder.$btrace$org$openjdk$btrace$runtime$auxiliary$HistoOnEventBtrace$onMethod(Ljava/lang/Object;)V @48: invokestatic
  Reason:
    Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'java/util/concurrent/atomic/AtomicInteger'
  Current Frame:
    bci: @48
    flags: { }
    locals: { 'java/lang/Object', 'java/lang/String', 'java/lang/Object' }
    stack: { 'java/lang/Object' }
  Bytecode:
    0x0000000: b201 a6b8 01ac 9a00 04b1 2ab8 01b2 b801
    0x0000010: b64c b201 ba2b b801 bd4d 2cc7 0014 04b8
    0x0000020: 01c1 4db2 01ba 2b2c b801 c557 a700 082c
    0x0000030: b801 c957 b201 a6b6 01ce b1b2 01a6 5a5f
    0x0000040: b601 d2b2 01a6 b601 ceb1               
  Exception Handler Table:
    bci [10, 59] => handler: 59
  Stackmap Table:
    same_frame(@10)
    append_frame(@47,Object[#24],Object[#105])
    same_frame(@52)
    full_frame(@59,{Object[#105]},{Object[#201]})

	at eval.btrace.alloc.TracedApp.step(TracedApp.java:52)
	at eval.btrace.alloc.TracedApp.doRun(TracedApp.java:33)
	at eval.btrace.alloc.TracedApp.lambda$1(TracedApp.java:27)
	at java.lang.Thread.run(Thread.java:748)
java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/apache/commons/lang3/builder/EqualsBuilder.$btrace$org$openjdk$btrace$runtime$auxiliary$HistoOnEventBtrace$onMethod(Ljava/lang/Object;)V @48: invokestatic
  Reason:
    Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'java/util/concurrent/atomic/AtomicInteger'
  Current Frame:
    bci: @48
    flags: { }
    locals: { 'java/lang/Object', 'java/lang/String', 'java/lang/Object' }
    stack: { 'java/lang/Object' }
  Bytecode:
    0x0000000: b201 a6b8 01ac 9a00 04b1 2ab8 01b2 b801
    0x0000010: b64c b201 ba2b b801 bd4d 2cc7 0014 04b8
    0x0000020: 01c1 4db2 01ba 2b2c b801 c557 a700 082c
    0x0000030: b801 c957 b201 a6b6 01ce b1b2 01a6 5a5f
    0x0000040: b601 d2b2 01a6 b601 ceb1               
  Exception Handler Table:
    bci [10, 59] => handler: 59
  Stackmap Table:
    same_frame(@10)
    append_frame(@47,Object[#24],Object[#105])
    same_frame(@52)
    full_frame(@59,{Object[#105]},{Object[#201]})

	at eval.btrace.alloc.TracedApp.step(TracedApp.java:52)
	at eval.btrace.alloc.TracedApp.doRun(TracedApp.java:33)
	at eval.btrace.alloc.TracedApp.lambda$0(TracedApp.java:26)
	at java.lang.Thread.run(Thread.java:748)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions