Find a strange problem about using project-panama on macos
David Holmes
david.holmes at oracle.com
Mon Aug 14 04:45:58 UTC 2023
On 14/08/2023 12:42 pm, 刘希晨 wrote:
>
> I have found a really strange problem when using project-panama on
> macos, and it might be a bug.
>
> *Environment*: JDK-21 ea build 34, cpu : M1 Pro, operating system :
> Ventura 13.5
>
> Here are the minimal reproducible codes:
>
> public class SimpleExample {
> public static void main(String[] args)throws Throwable {
> SymbolLookup crypto = SymbolLookup.libraryLookup("/Users/liuxichen/workspace/tenet-lib/lib/libcrypto.dylib", Arena.global());
> Thread.sleep(Long.MAX_VALUE);
> }
> }
>
> The libcrypto.dylib file is the OPENSSL dynamic library file, I think
> other libraries probably could cause the same problem.
>
> *Problem description*:
> A normal java program would work fine with *jconsole* and *jmap*, if
> running the above code in macos, jconsole won't be able to connect to
> the target process, and jmap will give the following error:
>
> *~/Dow/jdk-21/C/H/bin jps*
>
> 1665 RemoteMavenServer36
> 2673 Jps
> 532
> 1671 Launcher
> 1672 SimpleExample
> 1211
>
>
> * ~/Dow/jdk-21/C/H/bin ./jmap -histo:live,file=histo5.data 1672*
>
> Exception in thread"main" com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file /var/folders/k4/j5wzcbnd3m96s5lmqw_8lh8r0000gn/T/.java_pid1672: target process1672 doesn't respond within 10500ms or HotSpot VM not loaded
> at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:95)
> at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
> at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
> at jdk.jcmd/sun.tools.jmap.JMap.executeCommandForPid(JMap.java:127)
> at jdk.jcmd/sun.tools.jmap.JMap.histo(JMap.java:199)
> at jdk.jcmd/sun.tools.jmap.JMap.main(JMap.java:112)
These problems, and the workaround, suggest that a thread is preventing
the VM from going to safepoint, but I can't see why that should be the
case. If you apply the StartAttachListener workaround what does jstack
show you is happening?
David
-----
>
> Several tests:
> 1. The above code runs fine on windows and macos, and the process could
> be accessed by jconsole and jmap on windows, only fail on macos
> 2. The problem could be solved by adding VM options, for jconsole
> usable, add -Dcom.sun.management.jmxremote for jmap usable add
> -XX:+StartAttachListener , if there is no
> *SymbolLookup.libraryLookup*(), then jconsole and jmap would work well
> without these two arguments
>
> So, I guess there must be some internal logic that blocks the jconsole
> and jmap from entering java program inside
> *SymbolLookup.libraryLookup*(), please correct me if I am wrong
>
>
>
More information about the panama-dev
mailing list