question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Instrumenting constructors fails with VerificationError when interacting with classes that lack stack map frames

See original GitHub issue

The Java Allocation Instrumenter passes the ClassWriter.COMPUTE_MAXS flag to the ASM ClassWriter during constructor instrumentation. According to the ASM Javadocs:

for classes whose version is Opcodes.V1_7 of more, this option requires valid stack map frames. The maximum stack size is then computed from these frames, and from the bytecode instructions in between. If stack map frames are not present or must be recomputed, used COMPUTE_FRAMES instead.

Other Java agents (such as the JaCoCo code coverage agent) may use ASM to write modified class files without computing stack map frames by passing 0 as a flag to the ClassWriter object. This flag is mapped to MethodWriter.COMPUTE_NOTHING which means that neither stack map frames nor the maximum stack size are computed. The interaction between agents which modify bytecode and do not recompute stack map frames and the Allocation Instrumenter leads to VerifyErrors when the JVM attempts to verify the twice-modified classes.

To improve the resiliency of the Allocation Instrumenter, we recommend passing the ClassWriter.COMPUTE_FRAMES flag to the ASM ClassWriter in place of the ClassWriter.COMPUTE_MAXS flag.

I have a minimal reproducible test case which has been used to verify that making the change suggested above does resolve the issue; I can provide you with it if necessary. In parallel, I am also opening an issue with the JaCoCo project to adjust the flags that they pass to their ClassWriter. However, in theory any bytecode-modifying agent could elect not to write stack map frames so it seems most effectively to address the issue here in the Allocation Instrumenter.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jhmansoncommented, Jan 31, 2020

Yeah, I think that was just a mistake - we do the right thing in the AllocationInstrumenter class. I’ll push a fix. Thanks for reporting it.

0reactions
cgdeckercommented, Jun 23, 2020

Sorry for the long delay… I’ve released java-allocation-instrumenter 3.3.0 to Maven Central with this fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What kind of Java code requires stackmap frames?
The stack map frame specifies the verification type of each operand ... Class.privateGetDeclaredConstructors(Class.java:2658) at java.lang.
Read more >
Learning the Basics - Gradle User Manual
Whenever Gradle tries to resolve a module from a Maven or Ivy repository, it looks for a metadata file and the default artifact...
Read more >
Curtiss-Wright Technical Information Bulletin
Curtiss-Wright offers a variety of training courses, within SVS/TRN/100, which help delegates develop the skills needed to.
Read more >
https://huggingface.co/yuningm/bart-large-citesum/...
REF proposed a self-paced balance learning (SPBL) algorithm to address the problem of class imbalance in many classification tasks.
Read more >
Visual Geometry Group - University of Oxford
Efficient Two-Stage Detection of Human–Object Interactions with a Novel Unary–Pairwise Transformer. IEEE Conference on Computer Vision and Pattern ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found