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

VerifyBeforeExit is not honored when System.exit is called

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 13
    • Fix Version/s: 13
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:
      b20

      Description

      When running this test case:
      ==========
      $ cat TestExit.java
      public class TestExit {
        public static void main(String... args) {
          System.exit(-1);
        }
      }
      ==========

      with fastdebug or slowdebug (turns on VerifyBeforeExit), we don't actually execute the code path that perform the verification.

      The VM exits inside the this->loop() call:
      ==========
        // Wait for VM_Operations until termination
        this->loop();

        // Note the intention to exit before safepointing.
        // 6295565 This has the effect of waiting for any large tty
        // outputs to finish.
        if (xtty != NULL) {
          ttyLocker ttyl;
          xtty->begin_elem("destroy_vm");
          xtty->stamp();
          xtty->end_elem();
          assert(should_terminate(), "termination flag must be set");
        }

        // 4526887 let VM thread exit at Safepoint
        _cur_vm_operation = &halt_op;
        SafepointSynchronize::begin();

        if (VerifyBeforeExit) {
          HandleMark hm(VMThread::vm_thread());
          // Among other things, this ensures that Eden top is correct.
          Universe::heap()->prepare_for_verify();
          // Silent verification so as not to pollute normal output,
          // unless we really asked for it.
          Universe::verify();
        }
      ==========

      this->loop() terminates when we execute:

      #0 vm_exit (code=-1) at src/hotspot/share/runtime/java.cpp:532
      #1 0x00007ffff69b3dc0 in JVM_Halt (code=-1) at src/hotspot/share/prims/jvm.cpp:478
      #2 0x00007ffff5ac6bcd in Java_java_lang_Shutdown_halt0 (env=0x7ffff001eb80, ignored=0x7ffff5bed610, code=-1) at src/java.base/share/native/libjava/Shutdown.c:41

      and vm_exit schedules a VM_Exit vm operation, that runs inside this->loop().

      VM_Exit::doit calls vm_direct_exit:
      ==========
      void vm_direct_exit(int code) {
        notify_vm_shutdown();
        os::wait_for_keypress_at_exit();
        os::exit(code);
      }
      ==========

        Attachments

          Activity

            People

            Assignee:
            dholmes David Holmes
            Reporter:
            stefank Stefan Karlsson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: