RFR: JDK-8320890: [AIX] Find a better way to mimic dl handle equality [v2]

Joachim Kern jkern at openjdk.org
Mon Dec 4 12:33:26 UTC 2023


> On AIX, repeated calls to dlopen referring to the same shared library may result in different, unique dl handles to be returned from libc. In that it differs from typical libc implementations that cache dl handles.
> 
> This causes problems in the JVM with code that assumes equality of handles. One such problem is in the JVMTI agent handler. That problem was fixed with a local fix to said handler ([JDK-8315706](https://bugs.openjdk.org/browse/JDK-8315706)). However, this fix causes follow-up problems since it assumes that the file name passed to `os::dll_load()` is the file that has been opened. It prevents efficient, os_aix.cpp-local workarounds for other AIX issues like the *.so/*.a duality. See [JDK-8320005](https://bugs.openjdk.org/browse/JDK-8320005). As such, it is a hack that causes other, more uglier hacks to follow (see discussion of https://github.com/openjdk/jdk/pull/16604).
> 
> We propose a different, cleaner way of handling this:
> 
> - Handle this entirely inside the AIX versions of os::dll_load and os::dll_unload.
> - Cache dl handles; repeated opening of a library should return the cached handle.
> - Increase handle-local ref counter on open, Decrease it on close
> - Make sure calls to os::dll_load are matched to os::dll_unload (See [JDK-8320830](https://bugs.openjdk.org/browse/JDK-8320830)).
> 
> This way we mimic dl handle equality as it is implemented on other platforms, and this works for all callers of os::dll_load.

Joachim Kern has updated the pull request incrementally with one additional commit since the last revision:

  improve handling of nonexisting files

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/16920/files
  - new: https://git.openjdk.org/jdk/pull/16920/files/e756f496..0f6716db

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=16920&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=16920&range=00-01

  Stats: 16 lines in 1 file changed: 4 ins; 5 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/16920.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/16920/head:pull/16920

PR: https://git.openjdk.org/jdk/pull/16920


More information about the serviceability-dev mailing list