Skip to content

Commit ddacf92

Browse files
committed
8305765: CompressedClassPointers.java is unreliable due to ASLR
Reviewed-by: iklam
1 parent 4195246 commit ddacf92

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

src/hotspot/share/memory/metaspace.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ void Metaspace::global_initialize() {
793793

794794
// ...failing that, reserve anywhere, but let platform do optimized placement:
795795
if (!rs.is_reserved()) {
796+
log_info(metaspace)("Reserving compressed class space anywhere");
796797
rs = Metaspace::reserve_address_space_for_compressed_classes(size, true);
797798
}
798799

test/hotspot/jtreg/ProblemList.txt

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ runtime/os/TestTracePageSizes.java#G1 8267460 linux-aarch64
100100
runtime/os/TestTracePageSizes.java#Parallel 8267460 linux-aarch64
101101
runtime/os/TestTracePageSizes.java#Serial 8267460 linux-aarch64
102102
runtime/ErrorHandling/CreateCoredumpOnCrash.java 8267433 macosx-x64
103-
runtime/CompressedOops/CompressedClassPointers.java 8305765 generic-all
104103
runtime/StackGuardPages/TestStackGuardPagesNative.java 8303612 linux-all
105104
runtime/ErrorHandling/TestDwarf.java#checkDecoder 8305489 linux-all
106105
runtime/ErrorHandling/MachCodeFramesInErrorFile.java 8313315 linux-ppc64le

test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java

+25-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,8 @@
4444

4545
public class CompressedClassPointers {
4646

47-
static final String logging_option = "-Xlog:gc+metaspace=trace,cds=trace";
47+
static final String logging_option = "-Xlog:gc+metaspace=trace,metaspace=info,cds=trace";
48+
static final String reserveCCSAnywhere = "Reserving compressed class space anywhere";
4849

4950
// Returns true if we are to test the narrow klass base; we only do this on
5051
// platforms where we can be reasonably shure that we get reproducable placement).
@@ -56,6 +57,15 @@ static boolean testNarrowKlassBase() {
5657

5758
}
5859

60+
// Returns true if the output indicates that the ccs is reserved anywhere.
61+
static boolean isCCSReservedAnywhere(OutputAnalyzer output) {
62+
if (output.getOutput().contains(reserveCCSAnywhere)) {
63+
return true;
64+
} else {
65+
return false;
66+
}
67+
}
68+
5969
// CDS off, small heap, ccs size default (1G)
6070
// A small heap should allow us to place the ccs within the lower 32G and thus allow zero based encoding.
6171
public static void smallHeapTest() throws Exception {
@@ -67,7 +77,7 @@ public static void smallHeapTest() throws Exception {
6777
"-Xshare:off",
6878
"-XX:+VerifyBeforeGC", "-version");
6979
OutputAnalyzer output = new OutputAnalyzer(pb.start());
70-
if (testNarrowKlassBase()) {
80+
if (testNarrowKlassBase() && !isCCSReservedAnywhere(output)) {
7181
output.shouldContain("Narrow klass base: 0x0000000000000000");
7282
}
7383
output.shouldHaveExitValue(0);
@@ -84,7 +94,7 @@ public static void smallHeapTestWith1G() throws Exception {
8494
"-Xshare:off",
8595
"-XX:+VerifyBeforeGC", "-version");
8696
OutputAnalyzer output = new OutputAnalyzer(pb.start());
87-
if (testNarrowKlassBase()) {
97+
if (testNarrowKlassBase() && !isCCSReservedAnywhere(output)) {
8898
output.shouldContain("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3");
8999
}
90100
output.shouldHaveExitValue(0);
@@ -102,7 +112,7 @@ public static void largeHeapTest() throws Exception {
102112
"-Xshare:off",
103113
"-XX:+VerifyBeforeGC", "-version");
104114
OutputAnalyzer output = new OutputAnalyzer(pb.start());
105-
if (testNarrowKlassBase() && !Platform.isPPC() && !Platform.isOSX()) {
115+
if (testNarrowKlassBase() && !Platform.isPPC() && !Platform.isOSX() && !isCCSReservedAnywhere(output)) {
106116
// PPC: in most cases the heap cannot be placed below 32g so there
107117
// is room for ccs and narrow klass base will be 0x0. Exception:
108118
// Linux 4.1.42 or earlier (see ELF_ET_DYN_BASE in JDK-8244847).
@@ -128,7 +138,7 @@ public static void largeHeapAbove32GTest() throws Exception {
128138
"-XX:+VerifyBeforeGC", "-version");
129139
OutputAnalyzer output = new OutputAnalyzer(pb.start());
130140
if (testNarrowKlassBase()) {
131-
if (!(Platform.isAArch64() && Platform.isOSX())) { // see JDK-8262895
141+
if (!(Platform.isAArch64() && Platform.isOSX()) && !isCCSReservedAnywhere(output)) { // see JDK-8262895
132142
output.shouldContain("Narrow klass base: 0x0000000000000000");
133143
if (!Platform.isAArch64() && !Platform.isPPC() && !Platform.isOSX()) {
134144
output.shouldContain("Narrow klass shift: 0");
@@ -211,7 +221,9 @@ public static void smallHeapTestNoCoop() throws Exception {
211221
"-Xlog:cds=trace",
212222
"-XX:+VerifyBeforeGC", "-version");
213223
OutputAnalyzer output = new OutputAnalyzer(pb.start());
214-
output.shouldContain("Narrow klass base: 0x0000000000000000");
224+
if (!isCCSReservedAnywhere(output)) {
225+
output.shouldContain("Narrow klass base: 0x0000000000000000");
226+
}
215227
output.shouldHaveExitValue(0);
216228
}
217229

@@ -227,7 +239,9 @@ public static void smallHeapTestWith1GNoCoop() throws Exception {
227239
"-Xlog:cds=trace",
228240
"-XX:+VerifyBeforeGC", "-version");
229241
OutputAnalyzer output = new OutputAnalyzer(pb.start());
230-
output.shouldContain("Narrow klass base: 0x0000000000000000");
242+
if (!isCCSReservedAnywhere(output)) {
243+
output.shouldContain("Narrow klass base: 0x0000000000000000");
244+
}
231245
if (!Platform.isAArch64() && !Platform.isPPC()) {
232246
// Currently relax this test for Aarch64 and ppc.
233247
output.shouldContain("Narrow klass shift: 0");
@@ -247,7 +261,9 @@ public static void largeHeapTestNoCoop() throws Exception {
247261
"-Xlog:cds=trace",
248262
"-XX:+VerifyBeforeGC", "-version");
249263
OutputAnalyzer output = new OutputAnalyzer(pb.start());
250-
output.shouldContain("Narrow klass base: 0x0000000000000000");
264+
if (!isCCSReservedAnywhere(output)) {
265+
output.shouldContain("Narrow klass base: 0x0000000000000000");
266+
}
251267
if (!Platform.isAArch64() && !Platform.isPPC()) {
252268
// Currently relax this test for Aarch64 and ppc.
253269
output.shouldContain("Narrow klass shift: 0");

0 commit comments

Comments
 (0)