Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8305765

CompressedClassPointers.java is unreliable due to ASLR

XMLWordPrintable

    • b18

      CompressedClassPointers.java expect the compressed class space (CCS) to be reserved in a certain range to satisfy the following:

      output.shouldContain("Narrow klass base: 0x0000000000000000");

      https://github.com/openjdk/jdk/blob/a8871f5d26e5cb42c031c7b736ec30b1b147a2bc/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java#L61-L74

      However, this is not always possible due to Address Space Layout Randomization. This can be simulated on Linux/x64 with the following patch, which will cause the test to always fail.

      $ git diff
      diff --git a/src/hotspot/share/memory/metaspace.cpp b/src/hotspot/share/memory/metaspace.cpp
      index db9579e4652..efd711b57b0 100644
      --- a/src/hotspot/share/memory/metaspace.cpp
      +++ b/src/hotspot/share/memory/metaspace.cpp
      @@ -797,6 +797,7 @@ void Metaspace::global_initialize() {
       
             if (base != nullptr) {
               if (CompressedKlassPointers::is_valid_base(base)) {
      + if (0)
                 rs = ReservedSpace(size, Metaspace::reserve_alignment(),
                                    os::vm_page_size(), (char*)base);
               }

      ==============================
      Proposed fix:

      Add a VM log message to indicate whether it's able to reserve the CCS at the desired memory range. If not, the test cases in CompressedClassPointers.java should be skipped.

            ccheung Calvin Cheung
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: