Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading Pyroscope Java agent causes UnsatisfiedLinkError on systems running Homebrew OpenJDK #67

Closed
deejgregor opened this issue Sep 18, 2022 · 5 comments
Assignees

Comments

@deejgregor
Copy link

Here is what I get in code that calls java.lang.management.ManagementFactory.getRuntimeMXBean():

$ /opt/homebrew/opt/openjdk@11/bin/java -javaagent:/Users/dgregor/Downloads/pyroscope.jar -cp . ManagementTest
2022-09-18 16:42:07.026 [INFO] We recommend specifying application name via env variable PYROSCOPE_APPLICATION_NAME
2022-09-18 16:42:07.034 [INFO] For now we chose the name for you and it's javaspy.VeRo3kppTE6W-aS19qBBug
2022-09-18 16:42:07.034 [WARN] PYROSCOPE_SERVER_ADDRESS is not defined, using http://localhost:4040
2022-09-18 16:42:07.707 [INFO] Profiling started
Exception in thread "main" java.lang.UnsatisfiedLinkError: no management in java.library.path: [/Users/dgregor/Library/Java/Extensions, /Library/Java/Extensions, /Network/Library/Java/Extensions, /System/Library/Java/Extensions, /usr/lib/java, .]
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2673)
	at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
	at java.base/java.lang.System.loadLibrary(System.java:1873)
	at java.management/java.lang.management.ManagementFactory.lambda$static$8(ManagementFactory.java:1020)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.management/java.lang.management.ManagementFactory.<clinit>(ManagementFactory.java:1019)
	at ManagementTest.main(ManagementTest.java:6)
^CProfiling stopped after 0 seconds. No dump options specified
$ 

This appears to be due to an rpath issue in Homebrew OpenJDK builds that breaks loading of other shared objects after async-profiler is loaded (in my case, libmanagement.so/dylib): async-profiler/async-profiler#647

I opened up an issue on homebrew-core including a simple reproducer: Homebrew/homebrew-core#111068

I was able to resolve the issue with Pyroscope by rebuilding the pyroscope.jar with an updated version of your async-profiler fork that includes b5634b9 from async-profiler. Details are in the tail end of Homebrew/homebrew-core#111068.

@petethepig
Copy link
Member

Thanks for the report @deejgregor

We'll look into this soon!

@korniltsev
Copy link
Collaborator

korniltsev commented Sep 19, 2022

I applied async-profiler/async-profiler@b5634b9 to our branch
Released java agent 0.10.2 with the fix.
Please let us know if it fixed the problem.

Thank you for the report.

@deejgregor
Copy link
Author

Released java agent 0.10.2 with the fix.
Please let us know if it fixed the problem.

It does! Thanks for the quick turn around.

I also got a response from Homebrew, so I'll be giving that a try shortly, too (with the older version of the library): Homebrew/homebrew-core#111068 (comment)

@deejgregor
Copy link
Author

FYI, the underlying problem in Homebrew OpenJDK has been addressed: Homebrew/homebrew-core#111255

@Rperry2174
Copy link

Awesome thanks for the update @deejgregor !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants