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

BreakpointInfo::set allocates metaspace object in VM thread

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 17
    • None
    • hotspot
    • b16

    Description

      When Metaspace::allocate fails, it throws an exception. Since the VM thread cannot throw exceptions, it cannot call this function:


      We have an assert that's supposed to catch this, but it was coded incorrectly:

      https://github.com/openjdk/jdk/blob/master/src/hotspot/share/memory/metaspace.cpp#L797
        assert(!(DumpSharedSpaces && THREAD->is_VM_thread()), "sanity");

      Because DumpSharedSpaces is false when running the JVM regularly, this assert will always pass. Changing it to

        assert(!THREAD->is_VM_thread(), "can't allocate in VM thread because we cannot throw exception");

      will cause the following crash in test/com/sun/jdi/ModulesTest.java

      Stack: [0x00007fc3738fa000,0x00007fc3739fa000], sp=0x00007fc3739f87b0, free space=1017k
      Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0x126a9c1] Metaspace::allocate(ClassLoaderData*, unsigned long, MetaspaceObj::Type, Thread*)+0x1e1
      V [libjvm.so+0x1295321] MethodCounters::allocate(methodHandle const&, Thread*)+0x41
      V [libjvm.so+0x128b73e] Method::build_method_counters(Method*, Thread*)+0x3e
      V [libjvm.so+0x128bd93] BreakpointInfo::set(Method*)+0x123
      V [libjvm.so+0x106f066] JvmtiBreakpoint::each_method_version_do(void (Method::*)(int))+0x56
      V [libjvm.so+0x173caf7] VM_Operation::evaluate()+0x187
      V [libjvm.so+0x1760bdc] VMThread::inner_execute(VM_Operation*)+0x30c
      V [libjvm.so+0x1761535] VMThread::loop()+0x255
      V [libjvm.so+0x17617dc] VMThread::run()+0xcc
      V [libjvm.so+0x166f066] Thread::call_run()+0xf6
      V [libjvm.so+0x138a0f6] thread_native_entry(Thread*)+0x116

      Attachments

        Issue Links

          Activity

            People

              coleenp Coleen Phillimore
              iklam Ioi Lam
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: