JDK-7161796 : PhaseStringOpts::fetch_static_field tries to fetch field from the Klass instead of the mirror
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs24
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-04-16
  • Updated: 2013-07-18
  • Resolved: 2012-05-16
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 7 JDK 8 Other
7u40Fixed 8Fixed hs24Fixed
Description
The PhaseStringOpts::fetch_static_field function was not updated when the static fields were moved from the Klasses to the mirrors.

The failure is only apperent when we add/remove fields so that the offset of the Integer.sizeTable field is the same as any of the well-known fields in Klass.

Reproducer, which aligns Integer.sizeTable offset with Klass::_java_mirror:

diff -r b632e80fc9dc src/share/vm/oops/klass.hpp
--- a/src/share/vm/oops/klass.hpp	Mon Apr 16 08:57:18 2012 +0200
+++ b/src/share/vm/oops/klass.hpp	Mon Apr 16 15:59:21 2012 +0200
@@ -231,6 +231,9 @@
   // iteration.
   //
 
+  int _field1;
+  int _field2;
+  
   // Cache of last observed secondary supertype
   klassOop    _secondary_super_cache;
   // Array of all secondary supertypes

and run this with SPECjbb2000:
~/hg/hsx-gc/build/linux/linux_amd64_compiler2/jvmg/hotspot -XX:-CICompilerCountPerCPU -XX:CICompilerCount=1 -XX:+DisableExplicitGC -XX:+ShowMessageBoxOnError -XX:+UnlockDiagnosticVMOptions -XX:+VerifyBeforeGC -XX:+VerifyAfterGC -Xmx3840M -Xmn2g -XX:+UseSerialGC -XX:+PrintGC -cp jbb.jar:check.jar:reporter.jar:jbb_no_precompile.jar  spec.jbb.JBBmain -propfile SPECjbb.props

This gives:
Internal Error at memnode.cpp:1571, pid=27073, tid=139796898727680
assert(off != Type::OffsetBot || tp->is_oopptr()->klass()->is_java_lang_Object() || C->has_unsafe_access()) failed: Field accesses must be precise

Stack trace:
#2  0x00007f250a61edee in VMError::show_message_box (this=0x7f25007d15f0, buf=0x7f250adc0aa0 "gdb /proc/27073/exe 27073", buflen=2000) at /home/stefank/hg/hsx-gc/src/os/linux/vm/vmError_linux.cpp:60
#3  0x00007f250a61df82 in VMError::report_and_die (this=0x7f25007d15f0) at /home/stefank/hg/hsx-gc/src/share/vm/utilities/vmError.cpp:833
#4  0x00007f250a0b6d61 in report_vm_error (file=0x7f250a7ef200 "/home/stefank/hg/hsx-gc/src/share/vm/opto/memnode.cpp", line=1571, error_msg=0x7f250a7f1238 "assert(off != Type::OffsetBot || tp->is_oopptr()->klass()->is_java_lang_Object() || C->has_unsafe_access()) failed", 
    detail_msg=0x7f250a7f1218 "Field accesses must be precise") at /home/stefank/hg/hsx-gc/src/share/vm/utilities/debug.cpp:220
#5  0x00007f250a3f48ff in LoadNode::Value (this=0x7f24fd785780, phase=0x7f25007d2020) at /home/stefank/hg/hsx-gc/src/share/vm/opto/memnode.cpp:1566
#6  0x00007f250a4d2c87 in PhaseGVN::transform_no_reclaim (this=0x7f25007d2020, n=0x7f24fd785780) at /home/stefank/hg/hsx-gc/src/share/vm/opto/phaseX.cpp:689
#7  0x00007f250a4d2e0b in PhaseGVN::transform (this=0x7f25007d2020, n=0x7f24fd785780) at /home/stefank/hg/hsx-gc/src/share/vm/opto/phaseX.cpp:660
#8  0x00007f250a1c6d3e in GraphKit::make_load (this=0x7f25007d1bd0, ctl=0x0, adr=0x7f24fd7855f0, t=0x7f24fc0e1a18, bt=T_INT, adr_idx=13, require_atomic_access=false) at /home/stefank/hg/hsx-gc/src/share/vm/opto/graphKit.cpp:1429
#9  0x00007f2509f9b581 in GraphKit::make_load (this=0x7f25007d1bd0, ctl=0x0, adr=0x7f24fd7855f0, t=0x7f24fc0e1a18, bt=T_INT, adr_type=0x7f24fc0e3410, require_atomic_access=false) at /home/stefank/hg/hsx-gc/src/share/vm/opto/graphKit.hpp:474
#10 0x00007f250a1c6ef9 in GraphKit::load_array_element (this=0x7f25007d1bd0, ctl=0x0, ary=0x7f24fd785310, idx=0x7f24fd785058, arytype=0x7f24fc0e3410) at /home/stefank/hg/hsx-gc/src/share/vm/opto/graphKit.cpp:1618
#11 0x00007f250a561d51 in PhaseStringOpts::int_stringSize (this=0x7f25007d2a20, kit=..., arg=0x1bab748) at /home/stefank/hg/hsx-gc/src/share/vm/opto/stringopts.cpp:991
#12 0x00007f250a56481e in PhaseStringOpts::replace_string_concat (this=0x7f25007d2a20, sc=0x1b11538) at /home/stefank/hg/hsx-gc/src/share/vm/opto/stringopts.cpp:1291
#13 0x00007f250a565a6a in PhaseStringOpts::PhaseStringOpts (this=0x7f25007d2a20, gvn=0x7f25007d2020) at /home/stefank/hg/hsx-gc/src/share/vm/opto/stringopts.cpp:611
#14 0x00007f250a04feef in Compile::Compile (this=0x7f25007d2dc0, ci_env=0x7f25007d3790, compiler=0x1879398, target=0x7f24fd6d2a28, osr_bci=-1, subsume_loads=true, do_escape_analysis=true) at /home/stefank/hg/hsx-gc/src/share/vm/opto/compile.cpp:721
#15 0x00007f2509f94e24 in C2Compiler::compile_method (this=0x1879398, env=0x7f25007d3790, target=0x7f24fd6d2a28, entry_bci=-1) at /home/stefank/hg/hsx-gc/src/share/vm/opto/c2compiler.cpp:130
#16 0x00007f250a056eec in CompileBroker::invoke_compiler_on_method (task=0x19d4148) at /home/stefank/hg/hsx-gc/src/share/vm/compiler/compileBroker.cpp:1760
#17 0x00007f250a059872 in CompileBroker::compiler_thread_loop () at /home/stefank/hg/hsx-gc/src/share/vm/compiler/compileBroker.cpp:1597

Comments
Verified using specjbb2005. No crash observed: $ export JAVA_HOME=/net/sqenfs-1/export1/jdk/re/7u40/promoted/all/b29/binaries/linux-amd64/fastdebug/bin/java $ $JAVA_HOME/bin/java -XX:-CICompilerCountPerCPU -XX:CICompilerCount=1 -XX:+DisableExplicitGC -XX:+ShowMessageBoxOnError -XX:+UnlockDiagnosticVMOptions -XX:+VerifyBeforeGC -XX:+VerifyAfterGC -Xmx3840M -Xmn2g -XX:+UseSerialGC -XX:+PrintGC -cp jbb.jar:check.jar spec.jbb.JBBmain -propfile SPECjbb.props * Details of Runs Wh. Score Tot. Used Thread elapsed Trans. Count Resp. Time (s) Heap Heap spread > 120s Type total max (MB) (MB)% % 1 12894 1848 88 <0.01 <0.01 new_order 170107 4.66 .012 payment 117436 2.12 <0.01 order_status 11744 .249 <0.01 delivery 11744 10.9 8.66 stock_level 11743 .250 <0.01 cust_report 64760 10.9 7.90 2 16898 1901 112 1.40 1.63 new_order 1810622 136 9.30 payment 1248977 72.3 9.17 order_status 124897 2.23 <0.01 delivery 124898 104 10.3 stock_level 124898 1.94 <0.01 cust_report 687333 117 10.3 3 16157 1943 138 6.46 .767 new_order 1716628 264 11.3 payment 1184072 114 11.3 order_status 118408 3.20 .013 delivery 118407 79.8 11.2 stock_level 118409 31.4 9.65 cust_report 651518 162 9.66 4 15315 2036 166 1.89 .907 new_order 1629293 353 10.3 payment 1123896 128 12.6 order_status 112389 24.0 10.1 delivery 112390 112 10.1 stock_level 112389 13.5 9.86 cust_report 618498 257 12.6 5 14775 2036 555 4.06 <0.01 new_order 1557972 508 10.8 payment 1074517 119 10.8 order_status 107454 26.2 10.5 delivery 107450 171 10.8 stock_level 107453 15.7 10.8 cust_report 591070 284 10.8 6 14063 2036 223 1.02 2.37 new_order 1518455 432 11.3 payment 1047017 160 11.3 order_status 104702 83.6 11.2 delivery 104702 327 11.2 stock_level 104703 5.65 .016 cust_report 575585 316 11.2 7 13445 2175 248 5.01 2.06 new_order 1447671 531 11.7 payment 997962 185 11.9 order_status 99795 41.7 11.9 delivery 99795 325 11.9 stock_level 99795 28.9 11.5 cust_report 548230 376 15.3 8 13671 2175 1839 2.15 <0.01 new_order 1441224 721 12.3 payment 994260 238 12.3 order_status 99426 32.2 12.1 delivery 99426 338 12.3 stock_level 99426 31.7 12.2 cust_report 547297 426 12.3 SPECjbb2005 Version: [SPECjbb2005 1.07, March 15, 2006] Reporting page (C) Copyright SPEC, 2005. All rights reserved Output files: results/SPECjbbSingleJVM/SPECjbb.002.txt, results/SPECjbbSingleJVM/SPECjbb.002.raw, results/SPECjbbSingleJVM/SPECjbb.002.html Reporter messages: No errors. Valid run. Valid run, Score is 16123 There were no crashes, but I was unable to reproduce original failure too.
26-06-2013

EVALUATION http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/df3d4a91f7f6
29-06-2012

EVALUATION 7161796: PhaseStringOpts::fetch_static_field tries to fetch field from the Klass instead of the mirror Reviewed-by: twisti When the static fields were moved from the Klass to the Class some code in stringopts.cpp was missed. It's currently bening because the only place it's used is for a static final field, so it gets replaced with a constant. Fixed by replaced the Klass with the Class. I also added a short circuit for the constant path. Tested with specjbb2005 which exercises this path.
19-04-2012

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/df3d4a91f7f6
19-04-2012