JDK-6991315 : RedefineClasses fails with java.lang.VerifyError
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: hs20,7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,linux
  • CPU: generic,x86
  • Submitted: 2010-10-12
  • Updated: 2012-10-08
  • Resolved: 2010-11-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u25Fixed 7Fixed hs20Fixed
Related Reports
Relates :  
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
04-12-2010

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

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

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.
12-10-2010

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;
12-10-2010