grafana / pyroscope-java

pyroscope java integration
Apache License 2.0
83 stars 32 forks source link

Running agent without libstdc++ #84

Closed rrva closed 1 year ago

rrva commented 1 year ago

Using agent 0.11.1 with the docker base image amazoncorretto:19.0.2-alpine3.17 I get the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/?-pyroscope/libasyncProfiler-linux-musl-x64-f6ab1a383549585b63e2b7869345eafc0dca778.so: Error loading shared library libstdc++.so.6: No such file or directory (needed by /tmp/?-pyroscope/libasyncProfiler-linux-musl-x64-f6ab1a383549585b63e2b7869345eafc0dca778.so

Switching the docker base image to eclipse-temurin:19_36-jdk resolves the problem.

Can libstdc++ be linked statically into libasyncProfiler ? That way we can use a java base image which lacks it.

korniltsev commented 1 year ago

eclipse-temurin:19_36-jdk is based on Ubuntu 22.04 , not alpine. It has libstdc++ installed under /lib/x86_64-linux-gnu/libstdc++.so.6

amazoncorretto:19.0.2-alpine3.17 is based on alpine and has no libstdc++ installed you can add it by apk add libstdc++

While it is probably possible(I am not sure) to link c++ statically I would prefer not to do it (even try) just because genuine async-profiler does not do it and we want to be as close as possible to the upstream

rrva commented 1 year ago

Opened https://github.com/async-profiler/async-profiler/issues/729

rmak-cpi commented 1 year ago

While my scenario is not 100% the same, I actually got pyroscope java agent to work with adoptopenjdk/openjdk8:jre${java_version}-alpine image. It looks like the adopenjdk image has libstdc++.so.6 installed at /usr/glibc-compat/lib/libstdc++.so.6. Perhaps it is possible to install libstdc++ on corretto image via apk add libstdc++?

https://pkgs.alpinelinux.org/packages?name=libstdc%2B%2B&branch=edge&repo=&arch=&maintainer=

rrva commented 1 year ago

While my scenario is not 100% the same, I actually got pyroscope java agent to work with adoptopenjdk/openjdk8:jre${java_version}-alpine image. It looks like the adopenjdk image has libstdc++.so.6 installed at /usr/glibc-compat/lib/libstdc++.so.6. Perhaps it is possible to install libstdc++ on corretto image via apk add libstdc++?

https://pkgs.alpinelinux.org/packages?name=libstdc%2B%2B&branch=edge&repo=&arch=&maintainer=

The idea behind this issue is to not have to customize the base docker image at all, but still run the agent. For these cases it should work with whatever the base alpine image contains, which is no libstdc++

korniltsev commented 1 year ago

I will close this issue for now. We will update AP once the upstream issue is addressed.