United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6991315 RedefineClasses fails with java.lang.VerifyError
6991315 : RedefineClasses fails with java.lang.VerifyError

Details
Type:
Bug
Submit Date:
2010-10-12
Status:
Closed
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
2010-11-12
Component:
hotspot
OS:
linux,generic
Sub-Component:
runtime
CPU:
x86,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
hs20,7
Fixed Versions:
hs20

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

Description
In a special case RedefineClasses can fail with java.lang.VerifyError exception. Running test-case with -XX:TraceRedefineClasses=3 produces the following error output:
RedefineClasses-0x2: verify_byte_codes post merge-CP exception: 'java/lang/VerifyError'

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/jdk7/build/hotspot/rev/a4c7fe54bf3f
                                     
2010-12-04
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/a4c7fe54bf3f
                                     
2010-10-25
EVALUATION

The prolem seems to be in handling of switch padding in relocator.cpp. Relocator::handle_switch_pad()
moves the expanded instruction up, but the code does not clear the new padding area. This will throw 
(under the right circumstances) java.lang.VeryError in post merge-CP classfile verification in 
RedefineClasses code.
                                     
2010-10-12
WORK AROUND

If the verification is disabled using -Xverify:none, everything works fine.
                                     
2010-10-12
SUGGESTED FIX

The fix is very simple. The new switch padding area has to be cleared to satisfy the classfile verification.

diff --git a/src/share/vm/runtime/relocator.cpp b/src/share/vm/runtime/relocator.cpp
--- a/src/share/vm/runtime/relocator.cpp
+++ b/src/share/vm/runtime/relocator.cpp
@@ -641,6 +641,8 @@
       memmove(addr_at(bci +1 + new_pad),
               addr_at(bci +1 + old_pad),
               len * 4);
+      // clean the padding area; it will make verifier happy
+      memset(addr_at(bci +1), 0, new_pad);
     }
   }
   return true;
                                     
2010-10-12



Hardware and Software, Engineered to Work Together