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

CDS VM operations do not lock the heap

    XMLWordPrintable

    Details

    • Subcomponent:
      gc
    • Resolved In Build:
      b29
    • Verification:
      Verified

      Backports

        Description

        CDS VM operations (VM_PopulateDumpSharedSpace, VM_PopulateDynamicDumpSharedSpace and VM_Verify which is called directly once) which optionally do some heap verification do not lock the heap using the Heap_lock when they start.

        Any GC VM allocation operations may (temporarily) expose a raw pointer to the heap containing garbage as their result; so any VM operation that iterates over all of the heap must be guarded by the Heap_lock as well to ensure a consistent view.

        Otherwise the VM operation that iterates over the heap will come across uninitialized memory, crashing as described in this bug.

        Since that verification is only enabled in debug mode, product is not affected.

        Original description:
        ----------------------------

        Happened in gh actions when testing for JDK-8255978: "[windows] os::release_memory may not release the full range" (https://github.com/openjdk/jdk/pull/1143, see https://github.com/tstuefe/jdk/runs/1423207838?check_suite_focus=true)

        I am quite sure this has nothing to do with my change.

        ```
        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # SIGSEGV (0xb) at pc=0x00007fd88f32719d, pid=21277, tid=21302
        #
        # JRE version: OpenJDK Runtime Environment (16.0) (fastdebug build 16-internal+0-tstuefe-412da0658c96b4924aa425c3cabbe90543ee5d63)
        # Java VM: OpenJDK 64-Bit Server VM (fastdebug 16-internal+0-tstuefe-412da0658c96b4924aa425c3cabbe90543ee5d63, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
        # Problematic frame:
        # V [libjvm.so+0xaf519d] HeapRegion::block_size(HeapWordImpl* const*) const+0x16d
        #
        # CreateCoredumpOnCrash turned off, no core file dumped
        #
        # If you would like to submit a bug report, please visit:
        # https://bugreport.java.com/bugreport/crash.jsp
        #

        --------------- S U M M A R Y ------------

        Command Line: -Dtest.vm.opts=-XX:MaxRAMPercentage=25 -Djava.io.tmpdir=/home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/tmp -Dtest.tool.vm.opts=-J-XX:MaxRAMPercentage=25 -J-Djava.io.tmpdir=/home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/tmp -Dtest.compiler.opts= -Dtest.java.opts=-XX:-CreateCoredumpOnCrash -Dtest.jdk=/home/runner/jdk-linux-x64-debug/jdk-16-internal+0_linux-x64_bin-debug/jdk-16/fastdebug -Dcompile.jdk=/home/runner/jdk-linux-x64-debug/jdk-16-internal+0_linux-x64_bin-debug/jdk-16/fastdebug -Dtest.timeout.factor=4.0 -Dtest.nativepath=/home/runner/jdk-linux-x64-debug/jdk-16-internal+0_linux-x64_bin-tests-debug/hotspot/jtreg/native -Dtest.root=/home/runner/work/jdk/jdk/test/hotspot/jtreg -Dtest.name=runtime/handshake/AsyncHandshakeWalkStackTest.java -Dtest.file=/home/runner/work/jdk/jdk/test/hotspot/jtreg/runtime/handshake/AsyncHandshakeWalkStackTest.java -Dtest.src=/home/runner/work/jdk/jdk/test/hotspot/jtreg/runtime/handshake -Dtest.src.path=/home/runner/work/jdk/jdk/test/hotspot/jtreg/runtime/handshake:/home/runner/work/jdk/jdk/test/hotspot/jtreg/testlibrary:/home/runner/work/jdk/jdk/test/lib -Dtest.classes=/home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/classes/runtime/handshake/AsyncHandshakeWalkStackTest.d -Dtest.class.path=/home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/classes/runtime/handshake/AsyncHandshakeWalkStackTest.d:/home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/classes/testlibrary:/home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/classes/test/lib -Dtest.class.path.prefix=/home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/classes/runtime/handshake/AsyncHandshakeWalkStackTest.d:/home/runner/work/jdk/jdk/test/hotspot/jtreg/runtime/handshake:/home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/classes/testlibrary:/home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/classes/test/lib -XX:MaxRAMPercentage=25 -Djava.io.tmpdir=/home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/tmp -XX:-CreateCoredumpOnCrash -Djava.library.path=/home/runner/jdk-linux-x64-debug/jdk-16-internal+0_linux-x64_bin-tests-debug/hotspot/jtreg/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI com.sun.javatest.regtest.agent.MainWrapper /home/runner/work/jdk/jdk/build/run-test-prebuilt/test-support/jtreg_test_hotspot_jtreg_tier1_runtime/runtime/handshake/AsyncHandshakeWalkStackTest.d/main.0.jta

        Host: fv-az58-519, Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz, 2 cores, 6G, Ubuntu 18.04.5 LTS
        Time: Thu Nov 19 09:28:28 2020 UTC elapsed time: 0.376932 seconds (0d 0h 0m 0s)

        --------------- T H R E A D ---------------

        Current thread (0x00007fd854006600): GCTaskThread "GC Thread#1" [stack: 0x00007fd85cfb8000,0x00007fd85d0b8000] [id=21302]

        Stack: [0x00007fd85cfb8000,0x00007fd85d0b8000], sp=0x00007fd85d0b6ad0, free space=1018k
        Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
        V [libjvm.so+0xaf519d] HeapRegion::block_size(HeapWordImpl* const*) const+0x16d
        V [libjvm.so+0xc761bb] HeapRegion::verify(VerifyOption, bool*) const+0x13b
        V [libjvm.so+0xb854b8] VerifyRegionClosure::do_heap_region(HeapRegion*)+0xc8
        V [libjvm.so+0xc83c72] HeapRegionManager::par_iterate(HeapRegionClosure*, HeapRegionClaimer*, unsigned int) const+0x72
        V [libjvm.so+0xb8199c] G1ParVerifyTask::work(unsigned int)+0x3c
        V [libjvm.so+0x191368c] GangWorker::loop()+0xac
        V [libjvm.so+0x17c61a8] Thread::call_run()+0xf8
        V [libjvm.so+0x13b1b6e] thread_native_entry(Thread*)+0x10e


        siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000dd56dd5fc
        ```

        The following test failed in the JDK16 CI:

        runtime/handshake/AsyncHandshakeWalkStackTest.java

          Attachments

          1. AsyncHandshakeWalkStackTest.jtr
            20 kB
          2. hs_err_pid21277.log
            70 kB
          3. StressMe.java
            0.9 kB
          4. stressme.sh
            0.2 kB

            Issue Links

              Activity

                People

                Assignee:
                tschatzl Thomas Schatzl
                Reporter:
                stuefe Thomas Stuefe
                Votes:
                0 Vote for this issue
                Watchers:
                13 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: