Skip to content

Commit 7233897

Browse files
authored
Fix getaddrinfo() EBUSY on ARM (#825)
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.
1 parent 68856f0 commit 7233897

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pyi.Dockerfile

+10-10
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ RUN if grep -q "CentOS Linux 8" /etc/os-release ; then \
145145
./fix_centos8.sh; \
146146
fi
147147

148+
# update libmodulemd to fix https://bugzilla.redhat.com/show_bug.cgi?id=2004853
149+
RUN yum install -y epel-release && \
150+
yum install -y libmodulemd && \
151+
yum clean all
152+
148153
# python 3.10 installation
149154
WORKDIR /python
150155
RUN yum install -y \
@@ -166,11 +171,11 @@ RUN ./python310_build.sh
166171

167172
WORKDIR /app
168173

169-
RUN yum clean all && yum --setopt=skip_missing_names_on_install=False install -y \
170-
epel-release \
174+
RUN yum --setopt=skip_missing_names_on_install=False install -y \
171175
gcc \
172176
curl \
173-
libicu
177+
libicu && \
178+
yum clean all
174179

175180
# needed for aarch64 (for staticx)
176181
RUN set -e; \
@@ -212,13 +217,6 @@ COPY granulate-utils/glogger granulate-utils/glogger
212217
RUN python3 -m pip install --no-cache-dir -r requirements.txt
213218

214219
COPY exe-requirements.txt exe-requirements.txt
215-
# build on centos:8 of Aarch64 requires -lnss_files and -lnss_dns. the files are missing but the symbols
216-
# seem to be provided from another archive (e.g libc.a), so this "fix" bypasses the ld error of "missing -lnss..."
217-
# see https://github.com/JonathonReinhart/staticx/issues/219
218-
RUN if grep -q "CentOS Linux 8" /etc/os-release ; then \
219-
! test -f /lib64/libnss_files.a && ar rcs /lib64/libnss_files.a && \
220-
! test -f /lib64/libnss_dns.a && ar rcs /lib64/libnss_dns.a; \
221-
fi
222220
RUN python3 -m pip install --no-cache-dir -r exe-requirements.txt
223221

224222
# copy PyPerf, licenses and notice file.
@@ -277,6 +275,8 @@ RUN if [ "$(uname -m)" = "aarch64" ]; then \
277275
cd staticx && \
278276
git reset --hard 819d8eafecbaab3646f70dfb1e3e19f6bbc017f8 && \
279277
git apply ../staticx_patch.diff && \
278+
ln -s libnss_files.so.2 /lib64/libnss_files.so && \
279+
ln -s libnss_dns.so.2 /lib64/libnss_dns.so && \
280280
python3 -m pip install --no-cache-dir . ; \
281281
fi
282282

0 commit comments

Comments
 (0)