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

ProgrammableUpcallHandler::on_entry/on_exit access thread fields from native

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 19
    • core-libs

      ProgrammableUpcallHandler::on_entry modifies:

      context->new_handles = JNIHandleBlock::allocate_block(thread);
      thread->clear_pending_exception();

      Before transitioning to Java. Which means there can be a concurrent safepoint/handshake.
       
      ProgrammableUpcallHandler::on_exit modify and access same fields here:

      JNIHandleBlock::release_block(context->new_handles, thread);
      assert(!thread->has_pending_exception(), "Upcall can not throw an exception");

      After transitioning back to native.

      E.g. _free_handle_block, _pending_exception.

      This have two issues:
      - Is it safe today? I traced some code and FAICT it is.
      - These fields are now only allowed to be modified in a safepoint/handshake if target thread is waiting for the safepoint/handshake or by the thread it self. (I.e. it is not enough that thread is safepoint safe, it must actively be waiting for the safepoint/handshake)

      Is this a restriction that we want, and am I correct in saying that is safe?

            jvernee Jorn Vernee
            rehn Robbin Ehn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: