8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed

Mon, 20 Jan 2014 10:55:54 +0100

author
sjohanss
date
Mon, 20 Jan 2014 10:55:54 +0100
changeset 7842
34714dc91411
parent 7841
74472adaf90d
child 7845
347744b2cafe

8031686: G1: assert(_hrs.max_length() == _expansion_regions) failed
Summary: Using pointer_delta to avoid overflowing pointer calculation.
Reviewed-by: jwilhelm, ehelin

src/share/vm/gc_implementation/g1/g1BiasedArray.hpp file | annotate | diff | comparison | revisions
test/gc/g1/Test2GbHeap.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/g1/g1BiasedArray.hpp	Thu May 21 23:21:34 2015 -0700
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1BiasedArray.hpp	Mon Jan 20 10:55:54 2014 +0100
     1.3 @@ -75,7 +75,7 @@
     1.4      assert((uintptr_t)end % mapping_granularity_in_bytes == 0,
     1.5        err_msg("end mapping area address must be a multiple of mapping granularity %zd, is " PTR_FORMAT,
     1.6          mapping_granularity_in_bytes, p2i(end)));
     1.7 -    size_t num_target_elems = (end - bottom) / (mapping_granularity_in_bytes / HeapWordSize);
     1.8 +    size_t num_target_elems = pointer_delta(end, bottom, mapping_granularity_in_bytes);
     1.9      idx_t bias = (uintptr_t)bottom / mapping_granularity_in_bytes;
    1.10      address base = create_new_base_array(num_target_elems, target_elem_size_in_bytes);
    1.11      initialize_base(base, num_target_elems, bias, target_elem_size_in_bytes, log2_intptr(mapping_granularity_in_bytes));
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/gc/g1/Test2GbHeap.java	Mon Jan 20 10:55:54 2014 +0100
     2.3 @@ -0,0 +1,62 @@
     2.4 +/*
     2.5 + * Copyright (c) 2014, 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 Test2GbHeap
    2.29 + * @bug 8031686
    2.30 + * @summary Regression test to ensure we can start G1 with 2gb heap.
    2.31 + * @key gc
    2.32 + * @key regression
    2.33 + * @library /testlibrary
    2.34 + */
    2.35 +
    2.36 +import java.util.ArrayList;
    2.37 +
    2.38 +import com.oracle.java.testlibrary.OutputAnalyzer;
    2.39 +import com.oracle.java.testlibrary.ProcessTools;
    2.40 +
    2.41 +public class Test2GbHeap {
    2.42 +  public static void main(String[] args) throws Exception {
    2.43 +    ArrayList<String> testArguments = new ArrayList<String>();
    2.44 +
    2.45 +    testArguments.add("-XX:+UseG1GC");
    2.46 +    testArguments.add("-Xmx2g");
    2.47 +    testArguments.add("-version");
    2.48 +
    2.49 +    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testArguments.toArray(new String[0]));
    2.50 +
    2.51 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    2.52 +
    2.53 +    // Avoid failing test for setups not supported.
    2.54 +    if (output.getOutput().contains("Could not reserve enough space for 2097152KB object heap")) {
    2.55 +      // Will fail on machines with too little memory (and Windows 32-bit VM), ignore such failures.
    2.56 +      output.shouldHaveExitValue(1);
    2.57 +    } else if (output.getOutput().contains("G1 GC is disabled in this release")) {
    2.58 +      // G1 is not supported on embedded, ignore such failures.
    2.59 +      output.shouldHaveExitValue(1);
    2.60 +    } else {
    2.61 +      // Normally everything should be fine.
    2.62 +      output.shouldHaveExitValue(0);
    2.63 +    }
    2.64 +  }
    2.65 +}

mercurial