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

8145547 breaks AIX and and uses RTLD_NOLOAD incorrectly

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b118

      Description

      Change 8145547 uses the RTLD_NOLOAD flag when calling dlopen to probe the availability of the GTK libraries.

      But unfortunately RTLD_NOLOAD is not Posix and for example not available on AIX and BSD.

      I also found out, that the implementation of 8145547 contains a bug. It uses RTLD_NOLOAD in an incorrect way. The man page for dlopen clearly states that one of the two flags RTLD_LAZY or RTLD_NOW has to be included in the flags. But the current implementation uses RTLD_NOLOAD as single flag. Therefor the call to dlopen() currently always returns NULL, no difference if the corresponding library has been loaded already or not.

      The following short C program demonstrates the problem:

      #include <dlfcn.h>
      #include <stdio.h>

      int main(int argc, char **argv) {

        void* l = dlopen("libgtk-x11-2.0.so.0", RTLD_LAZY | RTLD_LOCAL);
        fprintf(stderr, "l = %p\n", l);

        dlerror();
        l = dlopen("libgtk-x11-2.0.so.0", RTLD_NOLOAD);
        fprintf(stderr, "l = %p (error = %s)\n", l, dlerror());

        l = dlopen("libgtk-x11-2.0.so.0", RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
        fprintf(stderr, "l = %p\n", l);

      }

      It will print:

      l = 0x10033f81c50
      l = (nil) (error = libgtk-x11-2.0.so.0: invalid mode for dlopen(): Invalid argument)
      l = 0x10033f81c50

        Issue Links

          Activity

          Hide
          simonis Volker Simonis added a comment -
          Notice, that the implementation of sun.awt.UNIXToolkit.check_gtk() breaks the contract of its caller UNIXToolkit.isNativeGTKAvailable() which states:

              /**
               * Returns true if the native GTK libraries are capable of being
               * loaded and are expected to work properly, false otherwise. Note
               * that this method will not leave the native GTK libraries loaded if
               * they haven't already been loaded. This allows, for example, Swing's
               * GTK L&F to test for the presence of native GTK support without
               * leaving the native libraries loaded. To attempt long-term loading
               * of the native GTK libraries, use the loadGTK() method instead.
               */

          But a call to isNativeGTKAvailable() will definitely load libgtk into the process space (see Java_sun_awt_UNIXToolkit_check_1gtk() -> gtk_check_version() -> check_version() -> gtk2_check()). However this was already true before 8145547 and is probably caused by the fix for 8048289 which simply uncommented the call to dlclose() in gtk2_check().
          Show
          simonis Volker Simonis added a comment - Notice, that the implementation of sun.awt.UNIXToolkit.check_gtk() breaks the contract of its caller UNIXToolkit.isNativeGTKAvailable() which states:     /**      * Returns true if the native GTK libraries are capable of being      * loaded and are expected to work properly, false otherwise. Note      * that this method will not leave the native GTK libraries loaded if      * they haven't already been loaded. This allows, for example, Swing's      * GTK L&F to test for the presence of native GTK support without      * leaving the native libraries loaded. To attempt long-term loading      * of the native GTK libraries, use the loadGTK() method instead.      */ But a call to isNativeGTKAvailable() will definitely load libgtk into the process space (see Java_sun_awt_UNIXToolkit_check_1gtk() -> gtk_check_version() -> check_version() -> gtk2_check()). However this was already true before 8145547 and is probably caused by the fix for 8048289 which simply uncommented the call to dlclose() in gtk2_check().
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/59fbc3a41b16
          User: simonis
          Date: 2016-05-07 08:05:00 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/59fbc3a41b16 User: simonis Date: 2016-05-07 08:05:00 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/59fbc3a41b16
          User: lana
          Date: 2016-05-11 16:05:08 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/59fbc3a41b16 User: lana Date: 2016-05-11 16:05:08 +0000

            People

            • Assignee:
              simonis Volker Simonis
              Reporter:
              simonis Volker Simonis
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: