You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ncurses-5's symlink approach to providing libtinfo.so is broken #89769
0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Describe the bug
When instantiated with abiVersion="5" the ncurses derivation creates a symlink from libtinfo.so to libncursesw.so. This is not a robust way to produce an ABI compatibility wrapper since the soname will be ncurses rather than tinfo as expected. This results in issues like #85924, where the dynamic linker notices the inconsistency and fails.
Does musl not like when soname != fname? I think it's a pretty common strategy when one library is replaced by another, to just symlink it, so we may see this same kind of issue elsewhere.
The copy & patchelf approach is probably the best, even if it does give some duplication (~500K).
Ncurses does have a --with-termlib flag that will split libncurses and libtinfo, but I don't think we want this because some things might expect libtinfo symbols in ncursesw.
Ncurses does have a --with-termlib flag that will split libncurses and libtinfo, but I don't think we want this because some things might expect libtinfo symbols in ncursesw.
Debian, Ubuntu, Fedora, CentOS, and RHEL all build ncurses --with-termlib=tinfo, and also provide libncursesw.so as a file whose contents is
Ncurses does have a --with-termlib flag that will split libncurses and libtinfo, but I don't think we want this because some things might expect libtinfo symbols in ncursesw.
Debian, Ubuntu, Fedora, CentOS, and RHEL all build ncurses --with-termlib=tinfo, and also provide libncursesw.so as a file whose contents is
Looks like a good solution. They delete libncurses{,w}.so, are those symlinks in that case? Could patchelf get confused when it it find those linker scripts or will it always use a more specific libncursesw.so.${version} file?
They delete libncurses{,w}.so, are those symlinks in that case?
They delete the symlinks libncurses.so -> libncurses.so.6, libncursesw.so -> libncursesw.so.6 and replace them with files containg INPUT(libncurses.so.6 -ltinfo), INPUT(libncursesw.so.6 -ltinfo).
Could patchelf get confused when it it find those linker scripts or will it always use a more specific libncursesw.so.${version} file?
libncursesw.so.6 is not “more specific” than libncursesw.so. The former is the soname stored in executables and loaded at runtime; the latter is found by ld at build time. patchelf should never see libncursesw.so.
#95141 is my proposal in the form of a patch, tested insofar as it results in a functioning bash linked against libncursesw.so.6 and libtinfow.so.6. (I have no idea whether .dylib and .dll should get similar treatments as .so here, so I’ve left those as is.)
They delete libncurses{,w}.so, are those symlinks in that case?
They delete the symlinks libncurses.so -> libncurses.so.6, libncursesw.so -> libncursesw.so.6 and replace them with files containg INPUT(libncurses.so.6 -ltinfo), INPUT(libncursesw.so.6 -ltinfo).
Could patchelf get confused when it it find those linker scripts or will it always use a more specific libncursesw.so.${version} file?
libncursesw.so.6 is not “more specific” than libncursesw.so. The former is the soname stored in executables and loaded at runtime; the latter is found by ld at build time. patchelf should never see libncursesw.so.
#95141 is my proposal in the form of a patch, tested insofar as it results in a functioning bash linked against libncursesw.so.6 and libtinfow.so.6. (I have no idea whether .dylib and .dll should get similar treatments as .so here, so I’ve left those as is.)
Ok. This should be also the case for common pre-compiled applications that we patch with autopatchelfHook? We don't compile all applications from source.
If a pre-compiled application doesn’t run on Debian, Ubuntu, Fedora, CentOS, or RHEL, it would be a very strange pre-compiled application indeed. It’s possible that some of them might want the unicode = false variant (which is not a problem, just something that would need to be selected)—though I doubt those are working with the current symlink setup, since libncurses.so.N and libncursesw.so.N are not binary compatible.
Compile with wide-character code. This makes a different version of
the libraries (e.g., libncursesw.so), which stores characters as
wide-characters,
NOTE: applications compiled with this configuration are not compatible
with those built for 8-bit characters. You cannot simply make a
symbolic link to equate libncurses.so with libncursesw.so
If an option value is given, that overrides the name of the terminfo
library. For instance, if the wide-character version is built, the
terminfo library would be named libtinfow. But the libtinfow interface
is upward compatible from libtinfo, so it would be possible to overlay
libtinfo.so with a "wide" version of libtinfow.so by renaming it with
this option.
Looks like the current setup is quite broken since it assumes it's safe to symlink all the non-unicode libraries to the unicode variant.
It looks like it's only safe for libtinfo.so to be a link to libtinfow.so (or a dynamic linker script after that change is implemented), but libncurses.so never should have been a link to libncursesw.so.
The incorrect links were introduced in 5a89a87. Prior to this commit linker scripts were used which might still be wrong when they're providing ncurses with ncursesw.
adds ncurses5/6 to LD_LIBRARY_PATH in buildfhsenv might be a good short term fix.
since adding /usr/lib to LD_LIBRARY_PATH was removed as part of #263201 , so just not to recreate the same problem as that PR solved - can i somehow easily add only particular libs? or do i have to create an extra dir with just those ncurses libs to add it to LD_LIBRARY_PATH in a clean way?
Adding something like export LD_LIBRARY_PATH=${lib.makeLibraryPath [pkgs.ncurses5 pkgs.ncurses6]}:$LD_LIBRARY_PATH to the start of the profile argument of buildFHSEnv should be sufficient to add only ncurses to LD_LIBRARY_PATH. Haven't tested that, might be wrong in some way.
0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Activity
bgamari commentedon Jun 7, 2020
I suspect the right way to address this is to rather build a wrapper shared object which
NEEDslibncursesand then exports its contents.Another more hacky solution would be to rather copy
libncurses.soandpatchelfit to give it the expectedsoname.[-]ncurses-5's libtinfo.so symlink is broken[/-][+]ncurses-5's symlink approach to providing libtinfo.so is broken[/+]bgamari commentedon Jun 7, 2020
Also relevant: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197317
matthewbauer commentedon Jun 7, 2020
Does musl not like when soname != fname? I think it's a pretty common strategy when one library is replaced by another, to just symlink it, so we may see this same kind of issue elsewhere.
The copy & patchelf approach is probably the best, even if it does give some duplication (~500K).
Ncurses does have a
--with-termlibflag that will split libncurses and libtinfo, but I don't think we want this because some things might expect libtinfo symbols in ncursesw.andersk commentedon Aug 10, 2020
Debian, Ubuntu, Fedora, CentOS, and RHEL all build ncurses
--with-termlib=tinfo, and also providelibncursesw.soas a file whose contents israther than a symlink.
https://sources.debian.org/src/ncurses/6.2-1/debian/rules/#L447
https://src.fedoraproject.org/rpms/ncurses/blob/f32/f/ncurses.spec#_213
https://git.centos.org/rpms/ncurses/blob/c8/f/SPECS/ncurses.spec#_224
Mic92 commentedon Aug 11, 2020
Looks like a good solution. They delete
libncurses{,w}.so, are those symlinks in that case? Could patchelf get confused when it it find those linker scripts or will it always use a more specificlibncursesw.so.${version}file?andersk commentedon Aug 11, 2020
They delete the symlinks
libncurses.so -> libncurses.so.6,libncursesw.so -> libncursesw.so.6and replace them with files containgINPUT(libncurses.so.6 -ltinfo),INPUT(libncursesw.so.6 -ltinfo).libncursesw.so.6is not “more specific” thanlibncursesw.so. The former is the soname stored in executables and loaded at runtime; the latter is found byldat build time.patchelfshould never seelibncursesw.so.#95141 is my proposal in the form of a patch, tested insofar as it results in a functioning
bashlinked againstlibncursesw.so.6andlibtinfow.so.6. (I have no idea whether.dyliband.dllshould get similar treatments as.sohere, so I’ve left those as is.)Mic92 commentedon Aug 11, 2020
Ok. This should be also the case for common pre-compiled applications that we patch with
autopatchelfHook? We don't compile all applications from source.andersk commentedon Aug 11, 2020
If a pre-compiled application doesn’t run on Debian, Ubuntu, Fedora, CentOS, or RHEL, it would be a very strange pre-compiled application indeed. It’s possible that some of them might want the
unicode = falsevariant (which is not a problem, just something that would need to be selected)—though I doubt those are working with the current symlink setup, sincelibncurses.so.Nandlibncursesw.so.Nare not binary compatible.Mic92 commentedon Aug 11, 2020
Thanks for clarification.
stale commentedon Feb 7, 2021
I marked this as stale due to inactivity. → More info
andersk commentedon Feb 7, 2021
Still an issue.
stale commentedon Aug 10, 2021
I marked this as stale due to inactivity. → More info
andersk commentedon Aug 10, 2021
Still an issue.
LunNova commentedon Nov 28, 2023
https://github.com/mirror/ncurses/blob/87c2c84cbd2332d6d94b12a1dcaf12ad1a51a938/INSTALL#L791-L798
https://github.com/mirror/ncurses/blob/87c2c84cbd2332d6d94b12a1dcaf12ad1a51a938/INSTALL#L1248-L1253
Looks like the current setup is quite broken since it assumes it's safe to symlink all the non-unicode libraries to the unicode variant.
It looks like it's only safe for libtinfo.so to be a link to libtinfow.so (or a dynamic linker script after that change is implemented), but libncurses.so never should have been a link to libncursesw.so.
The incorrect links were introduced in 5a89a87. Prior to this commit linker scripts were used which might still be wrong when they're providing ncurses with ncursesw.
permahorse commentedon Dec 2, 2023
Since this does not seem to ever get fixed - should we start relying on tricks like these in buildFHSEnvs ? https://github.com/nix-community/nix-environments/pull/54/files
and treat this as proper solution rather than a temporary hotfix?
LunNova commentedon Dec 2, 2023
Adding a workaround that specifically adds ncurses5/6 to LD_LIBRARY_PATH in buildfhsenv might be a good short term fix.
I tried fixing ncurses properly and it's a big pain, not ready to PR that.
permahorse commentedon Dec 2, 2023
since adding
/usr/libto LD_LIBRARY_PATH was removed as part of #263201 , so just not to recreate the same problem as that PR solved - can i somehow easily add only particular libs? or do i have to create an extra dir with just those ncurses libs to add it to LD_LIBRARY_PATH in a clean way?LunNova commentedon Dec 3, 2023
Adding something like
export LD_LIBRARY_PATH=${lib.makeLibraryPath [pkgs.ncurses5 pkgs.ncurses6]}:$LD_LIBRARY_PATHto the start of theprofileargument of buildFHSEnv should be sufficient to add only ncurses to LD_LIBRARY_PATH. Haven't tested that, might be wrong in some way.a workaround for ncurses