|Summary:||ldd fails to work on some binaries ("No space available for static Thread Local Storage")|
|Product:||Base System||Reporter:||Tobias Kortkamp <tobik>|
|Component:||bin||Assignee:||Konstantin Belousov <kib>|
|Severity:||Affects Some People||CC:||bofh, emaste, kib, markj, toolchain|
Description Tobias Kortkamp 2020-04-16 22:33:22 UTC
$ pkg install fd-find $ ldd /usr/local/bin/fd /usr/local/bin/fd: ldd: /usr/local/bin/fd: /usr/local/bin/fd: No space available for static Thread Local Storage /usr/local/bin/fd: exit status 1 This happens on 11.3, 12.1, and 13.0.
Comment 1 Konstantin Belousov 2020-04-22 16:32:07 UTC
Provide a tarball with the binary and all needed libraries.
Comment 2 Tobias Kortkamp 2020-04-22 16:36:35 UTC
(In reply to Konstantin Belousov from comment #1) You cannot run pkg install? It does not have any dependencies outside of libc, libthr, libgcc_s. https://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/fd-find-8.0.0.txz
Comment 3 Konstantin Belousov 2020-04-22 17:37:05 UTC
(In reply to Tobias Kortkamp from comment #2) I definitely do not want to run pkg install of some random package even on test machine. I unpacked the tarball and looked. The reason why the things fail are somewhat silly. First, the binary seems to be built as PIE, which results in the binary actually be dso. Then, the binary has TLS segment, compiled for initial exec mode. This mode is unsupported for dlopened libs, we reserve 128 bytes of slack for them, but fd requires ~6K of TLS data. ldd for libraries does dlopen(), and we cannot dlopen because the slack is only 128 bytes, while binary asks for 6k. So we abort.
Comment 4 commit-hook 2020-04-22 18:40:20 UTC
A commit references this bug: Author: kib Date: Wed Apr 22 18:39:46 UTC 2020 New revision: 360201 URL: https://svnweb.freebsd.org/changeset/base/360201 Log: rtld: ignore static TLS segments when tracing. For PIE binaries, ldd(1) performs dlopen(RTLD_TRACE) on the binary. It is legal for binary to use initial exec TLS mode, but when such binary (actually dso) is dlopened, we might not have enough free space in the finalized static TLS segment. Make ldd operational by skipping TLS space allocation, we are not going to execute any code from the dso anyway. Reported by: tobik PR: 245677 Sponsored by: The FreeBSD Foundation MFC after: 1 week Changes: head/libexec/rtld-elf/rtld.c head/libexec/rtld-elf/rtld.h
Comment 5 Mark Johnston 2020-06-02 15:20:42 UTC
MFCed to stable/12 in r360456.
Comment 6 Kubilay Kocak 2020-06-05 00:48:05 UTC
^Triage: Track stable merges (MFC)
Comment 7 Muhammad Moinur Rahman 2020-06-07 05:05:40 UTC
Any possibility that this will be merged into 11 after code slush takes off?
Comment 8 commit-hook 2020-06-07 09:39:03 UTC
A commit references this bug: Author: kib Date: Sun Jun 7 09:38:46 UTC 2020 New revision: 361889 URL: https://svnweb.freebsd.org/changeset/base/361889 Log: MFC r360201: Fix ldd for PIE binaries with static TLS segment. PR: 245677 Changes: _U stable/11/ stable/11/libexec/rtld-elf/rtld.c stable/11/libexec/rtld-elf/rtld.h
Comment 9 Muhammad Moinur Rahman 2020-06-07 11:12:30 UTC
(In reply to commit-hook from comment #8) Thanks.
Comment 10 Kubilay Kocak 2020-06-15 02:45:47 UTC
^Triage: Track merge to stable/11