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

JNI_GetCreatedJavaVMs returns a partially initialized JVM

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 21
    • hotspot
    • None
    • behavioral
    • minimal
    • Hide
      There is a risk that code in the wild, like the reproducer given in the bug report, is actually attaching to an in-the-process-of-being-created VM, late enough for the attach to actually succeed. With the proposed change such code would now find zero created VMs until initialization is complete. If that code proceeds without checking that a VM was created then it may now crash due to a null/uninitialized `JavaVM` pointer. Such code is unlikely due to the inherent raciness of the logic.
      Show
      There is a risk that code in the wild, like the reproducer given in the bug report, is actually attaching to an in-the-process-of-being-created VM, late enough for the attach to actually succeed. With the proposed change such code would now find zero created VMs until initialization is complete. If that code proceeds without checking that a VM was created then it may now crash due to a null/uninitialized `JavaVM` pointer. Such code is unlikely due to the inherent raciness of the logic.
    • Other
    • Implementation

      Summary

      JNI_GetCreatedJavaVMs will now only return a VM that has been successfully initialized.

      Problem

      JNI_GetCreatedJavaVMs will currently return a VM that has only just started to be created by JNI_CreateJavaVM. Consequently, if code then tries to attach to that VM it can crash in various ways, as the VM may not yet be ready for attaching.

      Solution

      JNI_GetCreatedJavaVMs will now only return a VM that has been successfully initialized.

      Specification

      There are no changes to the JNI specification. The specification for JNI_GetCreatedJavaVMs already states:

      Returns all Java VMs that have been created.

      and it is reasonable to expect that "created" means fully created, not "in the process of being created".

            dholmes David Holmes
            webbuggrp Webbug Group
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: