KEMBAR78
Fix UnsatisfiedLinkError when tmpdir is set to a relative path by Baraa-Hasheesh · Pull Request #1515 · async-profiler/async-profiler · GitHub
Skip to content

Conversation

Baraa-Hasheesh
Copy link
Contributor

Description

Simple fix for issue where the user might select a relative path for temporary directories using the java.io.tmpdir property

Related issues

#1451

Motivation and context

allow profiler release to run with process that overrides the java.io.tmpdir

How has this been tested?

I wanted to add an integration test somewhere but it wasn't straight forward to do so,
Adding tests would require doing some extra operations in make file & copying around resources to make it doable (specially due to the String resourceName = "/" + getPlatformTag() + "/libasyncProfiler.so"; line)

Test was done in manual capacity

Before change

java -Djava.io.tmpdir=./tmp-here -classpath /workplace/bhashesh/testing-profiler/target/classes:/local/home/bhashesh/.m2/repository/tools/profiler/async-profiler/4.2/async-profiler-4.2.jar org.example.App 

Exception in thread "main" java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: ./tmp-here/libasyncProfiler-5647789745460810263.so
        at java.base/java.lang.Runtime.load0(Runtime.java:764)
        at java.base/java.lang.System.load(System.java:1646)
        at one.profiler.AsyncProfiler.getInstance(AsyncProfiler.java:45)
        at one.profiler.AsyncProfiler.getInstance(AsyncProfiler.java:26)
        at org.example.App.main(App.java:13)

After change

java -Djava.io.tmpdir=./tmp-here -classpath /workplace/bhashesh/testing-profiler/target/classes:/local/home/bhashesh/.m2/repository/tools/profiler/async-profiler/4.2/async-profiler-4.2.jar org.example.App 

Hello World! 4.1-f9b7810

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@apangin apangin changed the title use getAbsolutePath instead of getPath Fix UnsatisfiedLinkError when tmpdir is set to a relative path Oct 1, 2025
@apangin apangin merged commit 6453ccc into async-profiler:master Oct 1, 2025
22 of 23 checks passed
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

Successfully merging this pull request may close these issues.

2 participants