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

Target class of upcall stub may be unloaded

XMLWordPrintable

        FFM upcall stubs embed a Method* of the target method in the stub. This Method* is read from the LambdaForm::vmentry field associated with the target MethodHandle at the time when the upcall stub is generated. The MH instance itself is stashed in a global JNI ref. So, there should be a reachability chain to the holder class: MH (receiver) -> LF (form) -> MemberName (vmentry) -> ResolvedMethodName (method) -> Class<?> (vmholder).

        However, it appears that, due to multiple threads racing to initialize the vmentry field of the LambdaForm of the target method handle of an upcall stub, it is possible that the vmentry is updated _after_ we embed the corresponding Method* into an upcall stub. Technically, it is fine to keep using a 'stale' vmentry, but the problem is that now the reachability chain is broken, since the upcall stub only extracts the target Method*, and doesn't keep the stale vmentry reachable. The holder class can then be unloaded, resulting in a crash.

          1. hs_err_1.log
            3.40 MB
            Jorn Vernee
          2. hs_err_unloaded.log
            1.85 MB
            Jorn Vernee
          3. TestUpcallStress.java
            4 kB
            Jorn Vernee
          4. xlog_unloaded.txt
            1.62 MB
            Jorn Vernee

              jvernee Jorn Vernee
              jvernee Jorn Vernee
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: