United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6978300 G1: debug builds crash if ParallelGCThreads==0
JDK-6978300 : G1: debug builds crash if ParallelGCThreads==0

Details
Type:
Bug
Submit Date:
2010-08-19
Status:
Closed
Updated Date:
2011-01-28
Project Name:
JDK
Resolved Date:
2010-12-21
Component:
hotspot
OS:
generic
Sub-Component:
gc
CPU:
generic
Priority:
P4
Resolution:
Won't Fix
Affected Versions:
hs19,7
Fixed Versions:
hs19

Related Reports
Backport:
Backport:
Backport:
Duplicate:
Relates:

Sub Tasks

Description
A debug build with -XX:+UseG1GC -XX:ParallelGCThreads=0 will crash during the first GC due to a null pointer dereference.

                                    

Comments
EVALUATION

The fix for 6966222 enabled collection of taskqueue statistics by default in debug builds.  This crashes when ParallelGCThreads==0 because it dereferences the _workers member (inherited from SharedHeap), which is null.  Must check whether _workers is null before dereferencing it in print_taskqueue_statistics() and reset_taskqueue_statistics().
                                     
2010-08-19
SUGGESTED FIX

diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
@@ -2753,7 +2753,7 @@
   print_taskqueue_stats_hdr(st);
 
   TaskQueueStats totals;
-  const int n = MAX2(workers()->total_workers(), 1);
+  const int n = workers() != NULL ? workers()->total_workers() : 1;
   for (int i = 0; i < n; ++i) {
     st->print("%3d ", i); task_queue(i)->stats.print(st); st->cr();
     totals += task_queue(i)->stats;
@@ -2764,7 +2764,7 @@
 }
 
 void G1CollectedHeap::reset_taskqueue_stats() {
-  const int n = MAX2(workers()->total_workers(), 1);
+  const int n = workers() != NULL ? workers()->total_workers() : 1;
   for (int i = 0; i < n; ++i) {
     task_queue(i)->stats.reset();
   }
                                     
2010-08-19
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-gc/hotspot/rev/8e5955ddf8e4
                                     
2010-08-25



Hardware and Software, Engineered to Work Together