RFR: JDK-8334217 : [AIX] Misleading error messages after JDK-8320005 [v2]
Joachim Kern
jkern at openjdk.org
Sat Jun 29 15:33:22 UTC 2024
On Sat, 29 Jun 2024 13:27:45 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> > But by using a central common definition for the string you at least minimize the chance of this breaking if someone changes the error messages, and signal too the code reader that the message may be used somewhere else.
>
> Great point. Thanks, thats good learning. We had worked on checking error numbers before, but there were limitations to that. Is the current #define code i pushed ,ok ?
Hi Suchi, what was the problem with error number? I would enrich the `dll_load_library()` interface by an eno to return the errno
`static void* dll_load_library(const char *filename, int* eno, char *ebuf, int ebuflen) {`
and also the `Aix_dlopen()` interface
`Aix_dlopen(const char* filename, int Flags, int* eno, const char** error_report) {`
Then you can return the errno from Aix_dlopen in two places
if (false == search_file_in_LIBPATH(filename, &libstat)) {
// file with filename does not exist
#ifdef ASSERT
result = ::dlopen(filename, Flags);
assert(result == nullptr, "dll_load: Could not stat() file %s, but dlopen() worked; Have to improve stat()", filename);
#endif
*error_report = "Could not load module .\nSystem error: No such file or directory";
+ *eno = ENOENT;
return nullptr;
}
and
// Library not yet loaded; load it, then store its handle in handle table
+ errno = 0;
result = ::dlopen(filename, Flags);
if (result != nullptr) {
g_handletable_used++;
(p_handletable + i)->handle = result;
(p_handletable + i)->inode = libstat.st_ino;
(p_handletable + i)->devid = libstat.st_dev;
(p_handletable + i)->hash = hash;
(p_handletable + i)->refcount = 1;
}
else {
// error analysis when dlopen fails
+ *eno = errno;
*error_report = ::dlerror();
if (*error_report == nullptr) {
*error_report = "dlerror returned no error description";
}
}
In os_aix.cpp you have to add and modify the following
// First try to load the existing file.
+ int eno = 0;
result = dll_load_library(filename, &eno, ebuf, ebuflen);
// If the load fails,we try to reload by changing the extension to .a for .so files only.
// Shared object in .so format dont have braces, hence they get removed for archives with members.
if (result == nullptr && eno == ENOENT && pointer_to_dot != nullptr && strcmp(pointer_to_dot, old_extension) == 0) {
snprintf(pointer_to_dot, sizeof(old_extension), "%s", new_extension);
result = dll_load_library(file_path, &eno, ebuf, ebuflen);
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19887#issuecomment-2198235671
More information about the hotspot-runtime-dev
mailing list