The bug was originally reported against async-profiler [1], but it turned out to be a JDK issue.
Before JDK 21, AttachListener responded with return code -1 if `load` command failed, i.e. dlopen() wasn't successful. Since JDK 21, it started returning 0 whether a library was loaded or not. This caused misbehavior of tools that relied on dynamic attach protocol: particularly, jattach and async-profiler.
The issue can be also observed without external tools. Because of the same bug, Attach API [2] no longer passes dlerror() message to user, making it harder to troubleshoot agent loading.
Example of an error message in JDK 11 - JDK 20:
Exception in thread "main" com.sun.tools.attach.AgentLoadException: Failed to load agent library: libasyncProfiler.so was not loaded./lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by libasyncProfiler.so)
at jdk.attach/sun.tools.attach.VirtualMachineImpl.execute(VirtualMachineImpl.java:221)
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:94)
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgentPath(HotSpotVirtualMachine.java:128)
at jdk.attach/com.sun.tools.attach.VirtualMachine.loadAgentPath(VirtualMachine.java:471)
at AttachTest.main(AttachTest.java:8)
The error message in JDK 21 - JDK 23:
Exception in thread "main" com.sun.tools.attach.AgentLoadException: libasyncProfiler.so was not loaded.
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:108)
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgentPath(HotSpotVirtualMachine.java:128)
at jdk.attach/com.sun.tools.attach.VirtualMachine.loadAgentPath(VirtualMachine.java:471)
at AttachTest.main(AttachTest.java:8)
Note that before JDK 21, the error message clearly pointed to the root cause related to GLIBC version. Since JDK 21, the error message is vague.
[1] https://github.com/async-profiler/async-profiler/issues/885
[2] https://docs.oracle.com/en/java/javase/21/docs/api/jdk.attach/com/sun/tools/attach/VirtualMachine.html