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

-XX:+ExitOnOutOfMemoryError calls exit while threads are running

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b17

      Description

      In JDK-8274072 we found that JDWP forcefully calls exit, which will run the destructors of global variables. This is problematic because other threads, like the GC threads, could still be using those objects.

      We have a similar problem with -XX:+ExitOnOutOfMemoryError. It calls os::exit(), and causes the same problem.

      I can reproduce this issue by adding this patch:
      ---
      $ git diff
      diff --git a/src/hotspot/share/gc/shared/gcTimer.cpp b/src/hotspot/share/gc/shared/gcTimer.cpp
      index ca835e30ed3..150e03be0af 100644
      --- a/src/hotspot/share/gc/shared/gcTimer.cpp
      +++ b/src/hotspot/share/gc/shared/gcTimer.cpp
      @@ -117,9 +117,16 @@ TimePartitions::TimePartitions() {
         clear();
       }
       
      +#include "runtime/os.hpp"
      +#include "runtime/globals.hpp"
       TimePartitions::~TimePartitions() {
         delete _phases;
         _phases = NULL;
      + if (UseNewCode) {
      + fprintf(stderr, "~TimePartitions sleep\n");
      + os::naked_short_sleep(999);
      + fprintf(stderr, "~TimePartitions sleep done\n");
      + }
       }
       
       void TimePartitions::clear() {
      ---

      and then running, say, SPECjbb2005:
      java -XX:+UseZGC -XX:+UseNewCode -Xlog:gc -Xmx32m -Xms32m -XX:+ExitOnOutOfMemoryError -cp jbb.jar:check.jar spec.jbb.JBBmain

      which results in:
      Terminating due to java.lang.OutOfMemoryError: Java heap space
      ~TimePartitions sleep
      ...
      # A fatal error has been detected by the Java Runtime Environment:
      ...
      # V [libjvm.so+0xd06b08] GCTimer::register_gc_start(TimeInstant<CompositeCounterRepresentation, CompositeElapsedCounterSource> const&)+0x8

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: