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
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
Attachments
Issue Links
- duplicates
-
JDK-8154994 The pre-loaded GTK library version cannot be detected by AWT Toolkit when being embedded in SWT
-
- Closed
-
- relates to
-
JDK-8145547 [AWT/Swing] Conditional support for GTK 3 on Linux
-
- Resolved
-