8210265: Crash in HSpaceCounters::update_used()
authortschatzl
Tue, 04 Sep 2018 12:17:23 +0200
changeset 51624 7ed777a14094
parent 51623 3ee917225506
child 51625 c265860d5d45
8210265: Crash in HSpaceCounters::update_used() Summary: Guard call to update HSpaceCounters with flag Reviewed-by: shade, sjohanss, kbarrett
src/hotspot/share/gc/g1/g1MonitoringSupport.cpp
test/hotspot/jtreg/gc/TestNoPerfCounter.java
--- a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp	Tue Sep 04 14:47:55 2018 +0800
+++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp	Tue Sep 04 12:17:23 2018 +0200
@@ -170,7 +170,9 @@
   // Given that this survivor space is not used, we update it here
   // once to reflect that its used space is 0 so that we don't have to
   // worry about updating it again later.
-  _from_space_counters->update_used(0);
+  if (UsePerfData) {
+    _from_space_counters->update_used(0);
+  }
 
   //  name "generation.0.space.2"
   // See _old_space_counters for additional counters
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/TestNoPerfCounter.java	Tue Sep 04 12:17:23 2018 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test TestNoPerfCounter
+ * @bug 8210265
+ * @requires vm.gc=="null"
+ * @library /test/lib /
+ * @summary Tests that disabling perf counters does not crash the VM
+ * @run main/othervm -XX:-UsePerfData TestNoPerfCounter
+ */
+
+public class TestNoPerfCounter {
+    public static void main(String[] args) throws Exception {
+        // Nothing to do
+    }
+}