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

JNI warnings in TryXShmAttach

    Details

    • Subcomponent:
    • Introduced In Build:
      b93
    • Introduced In Version:
      8
    • Resolved In Build:
      b120
    • CPU:
      generic
    • OS:
      linux
    • Verification:
      Verified

      Backports

        Description

        Run netbeans 7.3.1 with -Xcheck:jni. With JDK 7u40, only a few, seemingly harmless warnings are printed. With JDK8 b106, a large number of warnings are printed:

        Warning: Calling other JNI functions in the scope of Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical
        Warning: Calling other JNI functions in the scope of Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical
        Warning: Calling other JNI functions in the scope of Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical
        Warning: Calling other JNI functions in the scope of Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical
        ...

        The JNI functions that cause these warnings are Java_sun_java2d_loops_Blit_Blit and Java_sun_java2d_loops_MaskBlit_MaskBlit. They are trying to copy a source image (in memory buffer) to a destination image (in X11).

        [1] It first calls BufImg_GetRasInfo, which calls jni_GetPrimitiveArrayCritical, which calls GC_locker::jni_lock to prevent GC from happening.

        [2] Then, it calls X11SD_GetRasInfo, which tries to execute a Java method:

            #0 functionEnter (thr=0x7f69e4170800) at src/share/vm/prims/jniCheck.cpp:187
            #1 0x00007f6a6b987b3c in checked_jni_EnsureLocalCapacity (env=0x7f69e4170a20, capacity=3)
            #2 0x00007f6a6aa934ac in JNU_CallStaticMethodByName ()
            #3 0x00007f6a44d4113f in TryXShmAttach ()
            #4 0x00007f6a44d32825 in X11SD_CreateSharedImage ()
            #5 0x00007f6a44d33eb4 in X11SD_GetImage ()
            #6 0x00007f6a44d3464a in X11SD_GetRasInfo ()
            #7 0x00007f6a45062ee1 in Java_sun_java2d_loops_Blit_Blit ()

        Actually a few different methods are called while the primitive array is still being held.

        If one of these Java methods causes a GC, we will deadlock because GC has been disabled.

        The chance for deadlock may be higher for apps which refreshes the screen frequently and creates a lot of garbage.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  alitvinov Anton Litvinov
                  Reporter:
                  iklam Ioi Lam
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  12 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: