RFR: JDK-8320005 : Native library suffix impact on hotspot code in AIX [v2]
suchismith1993
duke at openjdk.org
Mon Nov 27 10:02:14 UTC 2023
On Fri, 24 Nov 2023 14:04:07 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> > > i would have to repeat the line 1132 and 1139 in os_aix.cpp again , if the condition fails for .so files, because i have to reload it again and check if the .a exists. In the shared code i had repeat less number of lines i believe. Do you suggest moving lines 1132 to 1139 to another function then ?
> >
> >
> > @tstuefe Any suggestion on this ?
>
> ```
> --- a/src/hotspot/os/aix/os_aix.cpp
> +++ b/src/hotspot/os/aix/os_aix.cpp
> @@ -1108,7 +1108,7 @@ bool os::dll_address_to_library_name(address addr, char* buf,
> return true;
> }
>
> -void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
> +static void* dll_load_inner(const char *filename, char *ebuf, int ebuflen) {
>
> log_info(os)("attempting shared library load of %s", filename);
>
> @@ -1158,6 +1158,35 @@ void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
> return nullptr;
> }
>
> +void* os::dll_load(const char *filename, char *ebuf, int ebuflen) {
> +
> + void* result = nullptr;
> +
> + // First try using *.so suffix; failing that, retry with *.a suffix.
> + const size_t len = strlen(filename);
> + constexpr size_t safety = 3 + 1;
> + constexpr size_t bufsize = len + safety;
> + char* buf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
> + strcpy(buf, filename);
> + char* const dot = strrchr(buf, '.');
> +
> + assert(dot != nullptr, "Attempting to load a shared object without extension? %s", filename);
> + assert(strcmp(dot, ".a") == 0 || strcmp(dot, ".so") == 0,
> + "Attempting to load a shared object that is neither *.so nor *.a", filename);
> +
> + sprintf(dot, ".so");
> + result = dll_load_inner(buf, ebuf, ebuflen);
> +
> + if (result == nullptr) {
> + sprintf(dot, ".a");
> + result = dll_load_inner(buf, ebuf, ebuflen);
> + }
> +
> + FREE_C_HEAP_ARRAY(char, buf);
> +
> + return result;
> +}
> +
> ```
Thanks for sharing !
I have worked on an alternate code as well, takling some lessons from your code.
I see a couple of issues
**Issue 1.**
assert(strcmp(dot, ".a") == 0 || strcmp(dot, ".so") == 0,
+ "Attempting to load a shared object that is neither *.so nor *.a", filename);
This fails as we have paths such as /usr/lib/libc.a(shr_64.0) .
However this check is already done in dll_load_inner already.
**Issue 2 :**
After calling dll_load_inner for .so ,after appending ".a" to filename, i face a segmentation fault. On looking into it further, i see the dlopen succeeds, but it is failing in stat64 being done using save_signature method for AIX.
I even tried by just supplying a string "libam_ibm_16.a" without doing any string operations and i still see the issue.
Does this look familiar ?
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/hotspot/openjdk/jdk-suchi/jdk/src/hotspot/share/prims/jvmtiAgent.cpp:307), pid=31719930, tid=258
# assert(false) failed: stat64x failed
#
# JRE version: (22.0) (fastdebug build )
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 22-internal-adhoc.hotspot.jdk, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, aix-ppc64)
# Core dump will be written. Default location: /home/hotspot/openjdk/jdk-suchi/j2se/j2se_dc/.gdc/7.3.0.15.0/runtime/j2secheckapp.p8-java1-hs01.checkapp/core or core.31719930
#
# An error report file with more information is saved as:
# /home/hotspot/openjdk/jdk-suchi/j2se/j2se_dc/.gdc/7.3.0.15.0/runtime/j2secheckapp.p8-java1-hs01.checkapp/hs_err_pid31719930.log
#
#
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16604#issuecomment-1827513022
More information about the hotspot-dev
mailing list