Skip to content

Commit 8713628

Browse files
Suchismith RoyMBaesken
Suchismith Roy
authored andcommitted
8334217: [AIX] Misleading error messages after JDK-8320005
Reviewed-by: jkern, mbaesken
1 parent 67979eb commit 8713628

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/hotspot/os/aix/os_aix.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ bool os::dll_address_to_library_name(address addr, char* buf,
10161016
return true;
10171017
}
10181018

1019-
static void* dll_load_library(const char *filename, char *ebuf, int ebuflen) {
1019+
static void* dll_load_library(const char *filename, int *eno, char *ebuf, int ebuflen) {
10201020

10211021
log_info(os)("attempting shared library load of %s", filename);
10221022
if (ebuf && ebuflen > 0) {
@@ -1044,7 +1044,7 @@ static void* dll_load_library(const char *filename, char *ebuf, int ebuflen) {
10441044
void* result;
10451045
const char* error_report = nullptr;
10461046
JFR_ONLY(NativeLibraryLoadEvent load_event(filename, &result);)
1047-
result = Aix_dlopen(filename, dflags, &error_report);
1047+
result = Aix_dlopen(filename, dflags, eno, &error_report);
10481048
if (result != nullptr) {
10491049
Events::log_dll_message(nullptr, "Loaded shared library %s", filename);
10501050
// Reload dll cache. Don't do this in signal handling.
@@ -1076,12 +1076,13 @@ void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
10761076
const char new_extension[] = ".a";
10771077
STATIC_ASSERT(sizeof(old_extension) >= sizeof(new_extension));
10781078
// First try to load the existing file.
1079-
result = dll_load_library(filename, ebuf, ebuflen);
1079+
int eno=0;
1080+
result = dll_load_library(filename, &eno, ebuf, ebuflen);
10801081
// If the load fails,we try to reload by changing the extension to .a for .so files only.
10811082
// Shared object in .so format dont have braces, hence they get removed for archives with members.
1082-
if (result == nullptr && pointer_to_dot != nullptr && strcmp(pointer_to_dot, old_extension) == 0) {
1083+
if (result == nullptr && eno == ENOENT && pointer_to_dot != nullptr && strcmp(pointer_to_dot, old_extension) == 0) {
10831084
snprintf(pointer_to_dot, sizeof(old_extension), "%s", new_extension);
1084-
result = dll_load_library(file_path, ebuf, ebuflen);
1085+
result = dll_load_library(file_path, &eno, ebuf, ebuflen);
10851086
}
10861087
FREE_C_HEAP_ARRAY(char, file_path);
10871088
return result;

src/hotspot/os/aix/porting_aix.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ static bool search_file_in_LIBPATH(const char* path, struct stat64x* stat) {
10351035
// specific AIX versions for ::dlopen() and ::dlclose(), which handles the struct g_handletable
10361036
// This way we mimic dl handle equality for a library
10371037
// opened a second time, as it is implemented on other platforms.
1038-
void* Aix_dlopen(const char* filename, int Flags, const char** error_report) {
1038+
void* Aix_dlopen(const char* filename, int Flags, int *eno, const char** error_report) {
10391039
assert(error_report != nullptr, "error_report is nullptr");
10401040
void* result;
10411041
struct stat64x libstat;
@@ -1047,6 +1047,7 @@ void* Aix_dlopen(const char* filename, int Flags, const char** error_report) {
10471047
assert(result == nullptr, "dll_load: Could not stat() file %s, but dlopen() worked; Have to improve stat()", filename);
10481048
#endif
10491049
*error_report = "Could not load module .\nSystem error: No such file or directory";
1050+
*eno = ENOENT;
10501051
return nullptr;
10511052
}
10521053
else {
@@ -1090,6 +1091,7 @@ void* Aix_dlopen(const char* filename, int Flags, const char** error_report) {
10901091
p_handletable = new_tab;
10911092
}
10921093
// Library not yet loaded; load it, then store its handle in handle table
1094+
errno = 0;
10931095
result = ::dlopen(filename, Flags);
10941096
if (result != nullptr) {
10951097
g_handletable_used++;
@@ -1101,6 +1103,7 @@ void* Aix_dlopen(const char* filename, int Flags, const char** error_report) {
11011103
}
11021104
else {
11031105
// error analysis when dlopen fails
1106+
*eno = errno;
11041107
*error_report = ::dlerror();
11051108
if (*error_report == nullptr) {
11061109
*error_report = "dlerror returned no error description";

src/hotspot/os/aix/porting_aix.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ class AixMisc {
115115

116116
};
117117

118-
void* Aix_dlopen(const char* filename, int Flags, const char** error_report);
118+
void* Aix_dlopen(const char* filename, int Flags, int *eno, const char** error_report);
119119

120120
#endif // OS_AIX_PORTING_AIX_HPP

0 commit comments

Comments
 (0)