8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs

Wed, 11 Sep 2013 10:19:16 +0200

author
tschatzl
date
Wed, 11 Sep 2013 10:19:16 +0200
changeset 5697
ff218fdb30ba
parent 5696
f7bc2ab5f659
child 5698
040895ec3920

8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
Summary: Correctly calculate the initialization value for the shift between object start and bitmap bit in the G1 mark bitmaps.
Reviewed-by: tonyp

src/share/vm/gc_implementation/g1/concurrentMark.cpp file | annotate | diff | comparison | revisions
test/gc/TestObjectAlignment.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Sep 11 10:14:32 2013 +0200
     1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Sep 11 10:19:16 2013 +0200
     1.3 @@ -481,9 +481,8 @@
     1.4  
     1.5  ConcurrentMark::ConcurrentMark(G1CollectedHeap* g1h, ReservedSpace heap_rs) :
     1.6    _g1h(g1h),
     1.7 -  _markBitMap1(MinObjAlignment - 1),
     1.8 -  _markBitMap2(MinObjAlignment - 1),
     1.9 -
    1.10 +  _markBitMap1(log2_intptr(MinObjAlignment)),
    1.11 +  _markBitMap2(log2_intptr(MinObjAlignment)),
    1.12    _parallel_marking_threads(0),
    1.13    _max_parallel_marking_threads(0),
    1.14    _sleep_factor(0.0),
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/gc/TestObjectAlignment.java	Wed Sep 11 10:19:16 2013 +0200
     2.3 @@ -0,0 +1,65 @@
     2.4 +/*
     2.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/**
    2.28 + * @test TestObjectAlignment
    2.29 + * @key gc
    2.30 + * @bug 8021823
    2.31 + * @summary G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
    2.32 + * @library /testlibrary
    2.33 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=8
    2.34 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=16
    2.35 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32
    2.36 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=64
    2.37 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=128
    2.38 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=256
    2.39 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=8
    2.40 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=16
    2.41 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32
    2.42 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=64
    2.43 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=128
    2.44 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=256
    2.45 + */
    2.46 +
    2.47 +import com.oracle.java.testlibrary.ProcessTools;
    2.48 +import com.oracle.java.testlibrary.OutputAnalyzer;
    2.49 +
    2.50 +public class TestObjectAlignment {
    2.51 +
    2.52 +  public static byte[] garbage;
    2.53 +
    2.54 +  private static boolean runsOn32bit() {
    2.55 +    return System.getProperty("sun.arch.data.model").equals("32");
    2.56 +  }
    2.57 +
    2.58 +  public static void main(String[] args) throws Exception {
    2.59 +    if (runsOn32bit()) {
    2.60 +      // 32 bit VMs do not allow setting ObjectAlignmentInBytes, so there is nothing to test. We still get called.
    2.61 +      return;
    2.62 +    }
    2.63 +    for (int i = 0; i < 10; i++) {
    2.64 +      garbage = new byte[1000];
    2.65 +      System.gc();
    2.66 +    }
    2.67 +  }
    2.68 +}

mercurial