changeset 48856:c866eaca24cb

8194984: 9 Null pointer dereference defect groups related to ciMethodData::bci_to_data() Reviewed-by: kvn
author dlong
date Wed, 31 Jan 2018 16:09:29 -0800
parents 19ef3f64bc10
children 23a07b0cf8a6
files src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp src/hotspot/share/c1/c1_GraphBuilder.cpp src/hotspot/share/opto/parse2.cpp src/hotspot/share/opto/parseHelper.cpp
diffstat 9 files changed, 22 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp	Thu Feb 01 14:19:04 2018 -0800
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp	Wed Jan 31 16:09:29 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -2532,7 +2532,7 @@
   ciMethodData* md = method->method_data_or_null();
   assert(md != NULL, "Sanity");
   ciProfileData* data = md->bci_to_data(bci);
-  assert(data->is_CounterData(), "need CounterData for calls");
+  assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
   assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
   Register mdo  = op->mdo()->as_register();
   __ mov_metadata(mdo, md->constant_encoding());
--- a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp	Thu Feb 01 14:19:04 2018 -0800
+++ b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp	Wed Jan 31 16:09:29 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3150,7 +3150,7 @@
   ciMethodData* md = method->method_data_or_null();
   assert(md != NULL, "Sanity");
   ciProfileData* data = md->bci_to_data(bci);
-  assert(data->is_CounterData(), "need CounterData for calls");
+  assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
   assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
   Register mdo  = op->mdo()->as_register();
   assert(op->tmp1()->is_register(), "tmp1 must be allocated");
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Thu Feb 01 14:19:04 2018 -0800
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Wed Jan 31 16:09:29 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2017, SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -2746,7 +2746,7 @@
   ciMethodData* md = method->method_data_or_null();
   assert(md != NULL, "Sanity");
   ciProfileData* data = md->bci_to_data(bci);
-  assert(data->is_CounterData(), "need CounterData for calls");
+  assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
   assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
   Register mdo = op->mdo()->as_register();
 #ifdef _LP64
--- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp	Thu Feb 01 14:19:04 2018 -0800
+++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp	Wed Jan 31 16:09:29 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2016, 2017, SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -2715,7 +2715,7 @@
   ciMethodData* md = method->method_data_or_null();
   assert(md != NULL, "Sanity");
   ciProfileData* data = md->bci_to_data(bci);
-  assert(data->is_CounterData(), "need CounterData for calls");
+  assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
   assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
   Register mdo  = op->mdo()->as_register();
   assert(op->tmp1()->is_double_cpu(), "tmp1 must be allocated");
--- a/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp	Thu Feb 01 14:19:04 2018 -0800
+++ b/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp	Wed Jan 31 16:09:29 2018 -0800
@@ -2761,7 +2761,7 @@
   ciMethodData* md = method->method_data_or_null();
   assert(md != NULL, "Sanity");
   ciProfileData* data = md->bci_to_data(bci);
-  assert(data->is_CounterData(), "need CounterData for calls");
+  assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
   assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
   Register mdo  = op->mdo()->as_register();
   assert(op->tmp1()->is_double_cpu(), "tmp1 must be allocated");
--- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp	Thu Feb 01 14:19:04 2018 -0800
+++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp	Wed Jan 31 16:09:29 2018 -0800
@@ -3504,7 +3504,7 @@
   ciMethodData* md = method->method_data_or_null();
   assert(md != NULL, "Sanity");
   ciProfileData* data = md->bci_to_data(bci);
-  assert(data->is_CounterData(), "need CounterData for calls");
+  assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
   assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
   Register mdo  = op->mdo()->as_register();
   __ mov_metadata(mdo, md->constant_encoding());
--- a/src/hotspot/share/c1/c1_GraphBuilder.cpp	Thu Feb 01 14:19:04 2018 -0800
+++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp	Wed Jan 31 16:09:29 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1556,8 +1556,6 @@
       }
       if (profile_return() && x->type()->is_object_kind()) {
         ciMethod* caller = state()->scope()->method();
-        ciMethodData* md = caller->method_data_or_null();
-        ciProfileData* data = md->bci_to_data(invoke_bci);
         profile_return_type(x, method(), caller, invoke_bci);
       }
     }
--- a/src/hotspot/share/opto/parse2.cpp	Thu Feb 01 14:19:04 2018 -0800
+++ b/src/hotspot/share/opto/parse2.cpp	Wed Jan 31 16:09:29 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2264,7 +2264,7 @@
     ciMethodData* methodData = method()->method_data();
     if (!methodData->is_mature())  break;
     ciProfileData* data = methodData->bci_to_data(bci());
-    assert( data->is_JumpData(), "" );
+    assert(data != NULL && data->is_JumpData(), "need JumpData for taken branch");
     int taken = ((ciJumpData*)data)->taken();
     taken = method()->scale_count(taken);
     target_block->set_count(taken);
--- a/src/hotspot/share/opto/parseHelper.cpp	Thu Feb 01 14:19:04 2018 -0800
+++ b/src/hotspot/share/opto/parseHelper.cpp	Wed Jan 31 16:09:29 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -459,7 +459,7 @@
     ciMethodData* md = method()->method_data();
     assert(md != NULL, "expected valid ciMethodData");
     ciProfileData* data = md->bci_to_data(cur_bci);
-    assert(data->is_JumpData(), "need JumpData for taken branch");
+    assert(data != NULL && data->is_JumpData(), "need JumpData for taken branch");
     increment_md_counter_at(md, data, JumpData::taken_offset());
   }
 
@@ -470,6 +470,7 @@
     ciMethodData* md = method()->method_data();
     if (osr_site) {
       ciProfileData* data = md->bci_to_data(cur_bci);
+      assert(data != NULL && data->is_JumpData(), "need JumpData for taken branch");
       int limit = (CompileThreshold
                    * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
       test_for_osr_md_counter_at(md, data, JumpData::taken_offset(), limit);
@@ -495,7 +496,7 @@
     ciMethodData* md = method()->method_data();
     assert(md != NULL, "expected valid ciMethodData");
     ciProfileData* data = md->bci_to_data(bci());
-    assert(data->is_BranchData(), "need BranchData for not taken branch");
+    assert(data != NULL && data->is_BranchData(), "need BranchData for not taken branch");
     increment_md_counter_at(md, data, BranchData::not_taken_offset());
   }
 
@@ -526,7 +527,7 @@
   ciMethodData* md = method()->method_data();
   assert(md != NULL, "expected valid ciMethodData");
   ciProfileData* data = md->bci_to_data(bci());
-  assert(data->is_CounterData(), "need CounterData for not taken branch");
+  assert(data != NULL && data->is_CounterData(), "need CounterData for not taken branch");
   increment_md_counter_at(md, data, CounterData::count_offset());
 }
 
@@ -537,7 +538,7 @@
   ciMethodData* md = method()->method_data();
   assert(md != NULL, "expected valid ciMethodData");
   ciProfileData* data = md->bci_to_data(bci());
-  assert(data->is_ReceiverTypeData(), "need ReceiverTypeData here");
+  assert(data != NULL && data->is_ReceiverTypeData(), "need ReceiverTypeData here");
 
   // Skip if we aren't tracking receivers
   if (TypeProfileWidth < 1) {
@@ -568,7 +569,7 @@
   ciMethodData* md = method()->method_data();
   assert(md != NULL, "expected valid ciMethodData");
   ciProfileData* data = md->bci_to_data(bci());
-  assert(data->is_RetData(), "need RetData for ret");
+  assert(data != NULL && data->is_RetData(), "need RetData for ret");
   ciRetData* ret_data = (ciRetData*)data->as_RetData();
 
   // Look for the target_bci is already in the table
@@ -601,7 +602,7 @@
   ciMethodData* md = method()->method_data();
   assert(md != NULL, "expected valid ciMethodData");
   ciProfileData* data = md->bci_to_data(bci());
-  assert(data->is_BitData(), "need BitData for checkcast");
+  assert(data != NULL && data->is_BitData(), "need BitData for checkcast");
   set_md_flag_at(md, data, BitData::null_seen_byte_constant());
 }
 
@@ -613,7 +614,7 @@
   assert(md != NULL, "expected valid ciMethodData");
 
   ciProfileData* data = md->bci_to_data(bci());
-  assert(data->is_MultiBranchData(), "need MultiBranchData for switch case");
+  assert(data != NULL && data->is_MultiBranchData(), "need MultiBranchData for switch case");
   if (table_index >= 0) {
     increment_md_counter_at(md, data, MultiBranchData::case_count_offset(table_index));
   } else {