Granulate / gprofiler

gProfiler is a system-wide profiler, combining multiple sampling profilers to produce unified visualization of what your CPU is spending time on.
https://profiler.granulate.io
Apache License 2.0
741 stars 54 forks source link

Fix getaddrinfo() EBUSY on ARM #825

Closed d3dave closed 1 year ago

d3dave commented 1 year ago

CPython uses glibc's getaddrinfo() to resolve hostnames. glibc tries to dynamically load the backend libs that implement the actual resolution, libnss_files.so and libnss_dns.so (as configured by staticx), which are unfortunately missing. When running staticx, it determines the libs to include by examining dependencies using ldd. For this reason, staticx adds a "fake" dependency on these two libs by linking libnssfix -- staticx's injected lib to configure nss to use only files and dns backends and ignore system configuration -- with nss_files and nss_dns. When building for ARM, we recompile staticx v0.13.6 with a patch that fixes some other static NSS issues (resolved in v0.13.7+) instead of using the prebuilt version from pypi.

The nss libs were never intended to be loaded by anything other than glibc itself, thus the lib.so -> lib.so.X symlinks for the linker are not installed. In turn, the linker complains that it cannot find -lnss_files and -lnss_dns. It appears that this was overcome by linking against fake static libraries, thus preventing the creation of dependencies for ldd to discover.

The solution is simply to replace these with the *.so symlinks ld expects.

Related Issue

Motivation and Context

How Has This Been Tested?

Built and tested on graviton instance.

Screenshots

Checklist:

Jongy commented 1 year ago

I assume you've verified that this fixes names resolution on Aarch64, right?

d3dave commented 1 year ago

I assume you've verified that this fixes names resolution on Aarch64, right?

yes