JDK-8059299 : assert(adr_type != NULL) failed: expecting TypeKlassPtr
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 7u80,8u40,9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-09-27
  • Updated: 2017-08-08
  • Resolved: 2014-10-02
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 JDK 9
7u80Fixed 8u40Fixed 9 b36Fixed
Related Reports
Relates :  
Relates :  
Description
Facebook reported crash in C2 in Parse::catch_inline_exceptions(). See attached hs_err file.
It looks like very old problem.

The problem happened during compilation of HiveMetastoreApiStats$1::call() method:

 public V call() throws Exception {
    try (TimeStat.BlockTimer timer = time.time()) {
        return callable.call();
    }
    catch (Exception e) {
        if (e instanceof MetaException) {
            metastoreExceptions.update(1);
        }
        else if (e instanceof TException) {
            thriftExceptions.update(1);
        }
        totalFailures.update(1);
        throw e;
    }
}
Comments
The failure happened when only Exception2 is thrown and it is checked second. 0 iload_0 1 invokestatic 4 <ConditionalExceptions.foo(I)V> 0 bci: 1 CounterData count(6700) 4 goto 51 16 bci: 4 JumpData taken(6694) displacement(208) 7 astore_1 8 aload_1 9 instanceof 6 <Exception1> 40 bci: 9 ReceiverTypeData count(4294967290) entries(1) 'Exception2'(6 Inf) 12 ifeq 26 88 bci: 12 BranchData taken(6) displacement(56) not taken(0) 15 getstatic 7 <ConditionalExceptions.counter1/I> 18 iconst_1 19 iadd 20 putstatic 7 <ConditionalExceptions.counter1/I> 23 goto 41 120 bci: 23 JumpData taken(0) displacement(104) 26 aload_1 27 instanceof 2 <Exception2> 144 bci: 27 ReceiverTypeData count(0) entries(1) 'Exception2'(6 1.00) 30 ifeq 41 192 bci: 30 BranchData taken(0) displacement(32) not taken(6) 33 getstatic 8 <ConditionalExceptions.counter2/I> 36 iconst_1 37 iadd 38 putstatic 8 <ConditionalExceptions.counter2/I> 41 getstatic 9 <ConditionalExceptions.counter/I> 44 iconst_1 45 iadd 46 putstatic 9 <ConditionalExceptions.counter/I> 49 aload_1 50 athrow 51 return
02-10-2014

Reproduction test: class Exception1 extends Exception {}; class Exception2 extends Exception {}; public class ConditionalExceptions { private static int counter1; private static int counter2; private static int counter; static void foo(int i) throws Exception { if ((i & 1023) == 2) { throw new Exception2(); } } static void test(int i) throws Exception { try { foo(i); } catch (Exception e) { if (e instanceof Exception1) { counter1++; } else if (e instanceof Exception2) { counter2++; } counter++; throw e; } } public static void main(String[] args) throws Throwable { for (int i = 0; i < 15000; i++) { try { test(i); } catch (Exception e) { // expected } } System.out.println("TEST PASSED"); } }
02-10-2014

ILW=Crash, rare, none = HLH=P2
29-09-2014

Suggested fix: diff -r fe1f65b0a2d8 src/share/vm/opto/doCall.cpp --- a/src/share/vm/opto/doCall.cpp Wed Sep 10 09:05:31 2014 -0700 +++ b/src/share/vm/opto/doCall.cpp Thu Sep 11 18:00:29 2014 -0700 @@ -802,6 +802,11 @@ if( ex_node->is_Phi() ) { ex_klass_node = new (C) PhiNode( ex_node->in(0), TypeKlassPtr::OBJECT ); for( uint i = 1; i < ex_node->req(); i++ ) { + Node* ex_in = ex_node->in(i); + if (ex_in == top() || ex_in == NULL) { + ex_klass_node->init_req(i, top()); + continue; + } Node* p = basic_plus_adr( ex_node->in(i), ex_node->in(i), oopDesc::klass_offset_in_bytes() ); Node* k = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT) ); ex_klass_node->init_req( i, k );
27-09-2014

*** save_ex_node: 900 CastPP === 899 575 [[ 891 909 909 1016 932 1110 958 978 970 993 1016 1004 1004 1013 ]] #java/lang/Exception:NotNull * Oop:java/lang/Exception:NotNull * !jvms: HiveMetastoreApiStats$1::call @ bci:97 RetryDriver::run @ bci:25 1013 CheckCastPP === 1011 900 [[ 923 1021 1021 1031 1040 1050 1066 1085 1077 1100 1110 1176 1176 ]] #org/apache/hadoop/hive/metastore/api/NoSuchObjectException:NotNull:exact * Oop:org/apache/hadoop/hive/metastore/api/NoSuchObjectException:NotNull:exact * !jvms: HiveMetastoreApiStats$1::call @ bci:118 RetryDriver::run @ bci:25 1000 Region === 1000 1097 _ 990 [[ 1000 942 1107 1108 1109 1110 1121 1124 1175 ]] !jvms: HiveMetastoreApiStats$1::call @ bci:135 RetryDriver::run @ bci:25 1110 Phi === 1000 1013 1 900 [[ 942 1115 1132 1150 1142 1165 1115 1172 1172 ]] #java/lang/Exception:NotNull * Oop:java/lang/Exception:NotNull * !jvms: HiveMetastoreApiStats$1::call @ bci:135 RetryDriver::run @ bci:25 *** ex_node: 900 CastPP === 899 575 [[ 891 909 909 1016 932 1110 958 978 970 993 1016 1004 1004 1013 ]] #java/lang/Exception:NotNull * Oop:java/lang/Exception:NotNull * !jvms: HiveMetastoreApiStats$1::call @ bci:97 RetryDriver::run @ bci:25 1013 CheckCastPP === 1011 900 [[ 923 1021 1021 1031 1040 1050 1066 1085 1077 1100 1110 1176 1176 ]] #org/apache/hadoop/hive/metastore/api/NoSuchObjectException:NotNull:exact * Oop:org/apache/hadoop/hive/metastore/api/NoSuchObjectException:NotNull:exact * !jvms: HiveMetastoreApiStats$1::call @ bci:118 RetryDriver::run @ bci:25 1000 Region === 1000 1097 _ 990 [[ 1000 942 1107 1108 1109 1110 1121 1124 1175 ]] !jvms: HiveMetastoreApiStats$1::call @ bci:135 RetryDriver::run @ bci:25 1110 Phi === 1000 1013 1 900 [[ 942 1115 1132 1150 1142 1165 1115 1172 1172 ]] #java/lang/Exception:NotNull * Oop:java/lang/Exception:NotNull * !jvms: HiveMetastoreApiStats$1::call @ bci:135 RetryDriver::run @ bci:25 There is exception handle in a method ('catch' block) and there are several code paths into it. It is somewhere in HiveMetastoreApiStats$1::call() @ bci:135 which is called from RetryDriver::run(). There are 3 paths into it. One path, at HiveMetastoreApiStats$1::call() @ bci:97, throws some general exception. An other, at HiveMetastoreApiStats$1::call @ bci:118, throws NoSuchObjectException. And third path is unknown (from your output). It could be compiler did not processed that bytecode yet, or it proved that the path is not taking. The failing code tries to construct a Phi of incoming exception classes but it misses the check that a class may be not defined on some paths. I added this missing check.
27-09-2014