Skip to content

hello: "`GLIBC_2.38' not found" when using LD_PRELOAD with the host system's libstdc++ (higher than nixpkgs') #287764

Closed

Description

@Brogolem35

Describe the bug

I installed Nix native package, added the user to the group, and enabled the daemon, as it was stated in the Arch Wiki. For testing I installed the nixpkgs.hello. It was installed successfully but didn't work. The error: hello: /nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/libc.so.6: version GLIBC_2.38' not found (required by /usr/lib/libstdc++.so.6)".
I also tried to install pgadmin4, as it was the reason I installed the Nix. It was also installed successfully but didn't run. The error: "/nix/store/0rwyq0j954a7143p0wzd4rhycny8i967-bash-5.2-p15/bin/bash: /nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/libc.so.6: version `GLIBC_2.38' not found (required by /usr/lib/libstdc++.so.6)"
I also reported this issue on Arch Linux Forum as well, and it seems the problem is related to Nix, as Nix (in stable channel) uses glibc version 2.37-45, but the Arch uses 2.38-7.
Nix being dependent on the libstdc++ might be the root of the issue.

Steps To Reproduce

  1. Install nix package from pacman.
  2. Enable the nix-daemon.service and add the user to the nix-users.
  3. Reboot.
  4. Add the channel nixpkgs-unstable or nixos-23.05 (the problem is present in both versions) and update with nix-.channel --update
  5. Install an application.
  6. Run the installed app.

Expected behavior

Running the installed app without any errors.

nix-env --version output

nix-env (Nix) 2.18.1

Additional context

I use Nix on Arch, btw.

Priorities

Add 👍 to issues you find important.

Activity

  1. abathur commented on Oct 22, 2023

    @abathur
    Member
  2. Brogolem35 commented on Oct 23, 2023

    @Brogolem35
    Author

    Unsetting the LF_PRELOAD seems to do the trick, but it feels not like a solution but a work-around.

  3. iFreilicht commented on Oct 24, 2023

    @iFreilicht
    Contributor

    Nix being dependent on the libstdc++ might be the root of the issue.

    True, it should depend on a libstdc++ inside /nix/store. This is definitely a build issue, but the question is whether it originates from the makefiles in the nix repo or the build instructions in the Arch package repository.

    Could you try uninstalling nix with pacman and installing it again with the determinate installer? It allows you to uninstall very easily again, so if you do want to run the version packaged by Arch, you can still do that later.

  4. Brogolem35 commented on Oct 24, 2023

    @Brogolem35
    Author

    Could you try uninstalling nix with pacman and installing it again with the determinate installer? It allows you to uninstall very easily again, so if you do want to run the version packaged by Arch, you can still do that later.

    I tried both the official Nix installer and the one from Determinate Systems before trying to install the programs I mentioned, and both of them crashed during the installation. I am don't know the reason why they crashed but I didn't bother, as the one that Arch shipped was installed successfully. And I now I don't want to uninstall Nix, as it may delete or corrupt my pgadmin4 configurations. But I may try them again in a VM and comeback with the results.

  5. nixos-discourse commented on Nov 6, 2023

    @nixos-discourse
  6. SomeoneSerge commented on Nov 6, 2023

    @SomeoneSerge
    Contributor

    Maybe we start un-setting the LD_* variables in the installer scripts 🤔 (as an opt-out behaviour)

  7. abathur commented on Nov 6, 2023

    @abathur
    Member

    Wouldn't that just shift the failures to post-install? (after the installer has told the user they have a working install)

  8. SomeoneSerge commented on Nov 6, 2023

    @SomeoneSerge
    Contributor

    Right, the nixpkgs software would still be broken. Then we need DT_RPATH back, again?

  9. nixos-discourse commented on Nov 27, 2023

    @nixos-discourse
  10. nixos-discourse commented on Dec 20, 2023

    @nixos-discourse
  11. cab404 commented on Jan 14, 2024

    @cab404
    Member

    this issue is not only important on Arch — it also affects old environments on NixOS (e.g if you develop on older haskell versions in direnv, and have your system on unstable)

  12. SomeoneSerge commented on Jan 19, 2024

    @SomeoneSerge
    Contributor

    Hey, I appreciate everyone chiming in, but we should try to keep this relevant and "noise-free". Maybe we should close or lock this issue, and actually open one in Nixpkgs instead.

    First off, yes, there has been some work and exploration happening related to this issue, e.g. #248547 and the PRs referenced therein.

    The way (glibc's) dynamic loader handles DT_RUNPATH today (compared to DT_RPATH) presents a relatively deep issue to how Nixpkgs chooses to link shared libraries. This is only an issue when using Nixpkgs programs on other (FHS) distributions, and only when they abuse something like LD_LIBRARY_PATH.

    This repo is concerned specifically with the development of Nix. Nixpkgs-specific issues (e.g. dynamic loading errors in hello, as opposed to the nix binary) should be reported in https://github.com/NixOS/nixpkgs/issues/.

    Before posting any new reports in this issue, please test which libc and libstdc++ the Nix binary ends up loading: try running LD_DEBUG=libs nix --version (similarly, if reporting to Nixpkgs, LD_DEBUG=libs hello) and gist the logs. Do verify the logs mention loading libc.so* from a FHS location like /usr/lib. The logs will also mention why the loader chose to look up the library in /usr/lib. If the logs say that /usr/lib was in the LD_LIBRARY_PATH, you've encountered the exact same issue and reporting it will add noise:

       3479124:     find library=libc.so.6 [0]; searching                                                     
       3479124:      search path=/usr/lib             (LD_LIBRARY_PATH)                   
       3479124:       trying file=/usr/lib/libc.so.6                                   
       3479124:      search path=/nix/store/5k91mg4qjylxbfvrv748smfh51ppjq0g-xxxxxxx-3.11.6/lib             (RUNPATH from file /nix/store/5k91mg4qjylxbfvrv748smfh51ppjq0g-xxxxxxx-3.11.6/bin/xxxxxx)
       3479124:       trying file=/nix/store/5k91mg4qjylxbfvrv748smfh51ppjq0g-xxxxxxx-3.11.6/lib/libc.so.6 
    ...
    

    FWIW, I tried running LD_DEBUG=libs LD_LIBRARY_PATH=/usr/lib nix --version on my NixOS system with nix deployed from Nixpkgs, and it the logs showed an empty LD_LIBRARY_PATH, indicating that nix probably unsets the variable. So I do not expect this specific issue to be encountered in Nix itself, only in other Nixpkgs-built software like hello:

       3771467:     find library=libc.so.6 [0]; searching                                                                                                                                                                
       3771467:      search path=           (LD_LIBRARY_PATH)
    

    Do report if you get similar errors when using the nix binary and

    • you've confirmed that your FHS environment doesn't force, in any obvious way, the dynamic loader to use the wrong libc instead of the one Nix directly links to through the RUNPATH;
    • or you get linkage-related errors with the nixStatic (because it shouldn't involve any dynamic linkage).

    @cab404 this shouldn't be an issue if you're not mixing different channels in your dev environment and not mixing the "system" and the dev environment's packages. The issue should only present itself when you try to load a library linked against a newer libc in a process that has already loaded the old libc. This might hypothetically happen with e.g. the impure userspace drivers deployed in /run/opengl-driver/lib in which case you do have to use work-arounds like nixGL. If you're observing this error under different circumstances, please file an issue in Nixpkgs (I'd appreciate a ping too).

    If one needs help diagnosing, they should please reach out in the Nix/NixOS support room on matrix, or at https://discourse.nixos.org.

    Thanks!

  13. Ashvith10 commented on Feb 9, 2024

    @Ashvith10
    Contributor

    Has this issue been resolved? Because I still have problem launching applications in Nix Flakes on a Guix System.

  14. SomeoneSerge commented on Feb 9, 2024

    @SomeoneSerge
    Contributor

    Has this issue been resolved? Because I still have problem launching applications in Nix Flakes on a Guix System.

    • The issue of DT_RUNPATH having a lower priority than LD_LIBRARY_PATH has not been resolved yet.
    • The issue of distributions potentially abusing the high-priority LD_PRELOAD and LD_LIBRARY_PATH... isn't suggestive of a solution?
    • The general issue of magically always choosing the newest libc/libstdc++ hasn't been resolved

    In which way exactly do applications from nix flakes fail to launch for you on that Guix system?

  15. SomeoneSerge commented on Feb 9, 2024

    @SomeoneSerge
    Contributor

    Unsetting the LF_PRELOAD seems to do the trick, but it feels not like a solution but a work-around.

    @Brogolem35 could you elaborate, what were the contents of LD_PRELOAD and why/how was it set?

    Could you confirm that you had an LD_PRELOAD set which forced the newer (Archlinux's) libstdc++ to be loaded, but not the newer libc?

  16. 5 remaining items

  17. SomeoneSerge commented on Feb 9, 2024

    @SomeoneSerge
    Contributor

    @Ashvith10 none of this should ever be required. You would help the community if you had managed to figure out why does the loader "incorrectly" choose the libstdc++ deployed by Guix. It shouldn't.

  18. Ashvith10 commented on Feb 10, 2024

    @Ashvith10
    Contributor

    @SomeoneSerge I wish I knew how to read trace from LD_DEBUG=libs setzer. Here's the details from my console: dump.log

  19. Ashvith10 commented on Feb 10, 2024

    @Ashvith10
    Contributor

    I think the issues probably starts from here?

  20. SomeoneSerge commented on Feb 10, 2024

    @SomeoneSerge
    Contributor
    10864:	calling init: /run/current-system/profile/lib/gio/modules/libgioenvironmentproxy.so
    ...
    10864:	find library=libstdc++.so.6 [0]; searching
    10864:	 search path=...:/gnu/store/6ncav55lbk5kqvwwflrzcr41hp5jbq0c-gcc-11.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../..		(RUNPATH from file /run/current-system/profile/lib/gio/modules/libgiolibproxy.so)
        10864:	calling init: /gnu/store/6ncav55lbk5kqvwwflrzcr41hp5jbq0c-gcc-11.3.0-lib/lib/libstdc++.so.6
    

    I don't see what's loading libgioenvironment and why it's a path in /run, but at least we see that /run/current-system is how we reach /gnu

    EDIT:

    My guess is that we don't see any look-up process for libgioenvironmentproxy because it must've been loaded by absolute path rather than by name. This very likely happens because of some of the global configuration deployed by Guix. I'm not familiar with GIO but I imagine it's something mildly cursed, maybe akin to nsswitch.

    You're observing an error because none of the nix-built programs loaded before libgio... depend on libstdc++ so they do not load it. The GIO "plugins" deployed by Guix do, and their libstdc++ is loaded first. The nix-built libwebkitgtk-6.0.so.4 loaded later needs a newer libstdc++ but its space is already occupied

    EDIT:

    I wish I knew how to read trace from LD_DEBUG=libs setzer

    That's quite ok, that's why I suggested reaching out in the chat

  21. Brogolem35 commented on Feb 10, 2024

    @Brogolem35
    Author

    Unsetting the LF_PRELOAD seems to do the trick, but it feels not like a solution but a work-around.

    @Brogolem35 could you elaborate, what were the contents of LD_PRELOAD and why/how was it set?

    Could you confirm that you had an LD_PRELOAD set which forced the newer (Archlinux's) libstdc++ to be loaded, but not the newer libc?

    I used set it in .zshrc with export LD_PRELOAD=/usr/lib/libstdc++.so.6.

    The reason why I set it was that for some reason the matplotlib that was shipped by conda required it to work.

  22. Ashvith10 commented on Feb 10, 2024

    @Ashvith10
    Contributor

    @Brogolem35 so in your case, it isn't even able to detect system's shared object, let alone Nix, I presume? But then, since you're on Arch, your system's and Nix's shared object must have a small version gap? What you're doing is still not a fix - it's merely a workaround, just like my suggestion above, and most of the apps on older channels won't work, which can be quite a hindrance for anyone using it for production.

  23. SomeoneSerge commented on Feb 10, 2024

    @SomeoneSerge
    Contributor
     I used set it in .zshrc with export LD_PRELOAD=/usr/lib/libstdc++.so.6.
    

    Ok, so it wasn't a Nixpkgs issue, and it wasn't an Archlinux issue either. Thanks for expounding this! The resolution is that LD_PRELOAD used this way isn't supported, because it overrides the linker's normal behaviour and force-loads the wrong libstdc++. Btw it probably would've worked if you preloaded libc too (bc in the original description you had the nixpkgs' older libc with archlinux's newer libstdc++)

    I think we can close this now.

    so in your case, it isn't even able to detect system's shared object, let alone Nix, I presume? But then, since you're on Arch, your system's and Nix's shared object must have a small version gap?

    The gaps don't matter, what matters is that one must load libstdc++ at least as new as the one used at build/link time

    What you're doing is still not a fix - it's merely a workaround

    I'd say there's nothing to work around. LD_PRELOAD force-loads the wrong libstdc++ without a compatible libc, so it explicitly breaks the program deployed by nix.

  24. Ashvith10 commented on Feb 10, 2024

    @Ashvith10
    Contributor

    @SomeoneSerge so my issue is different from @Brogolem35 's? At least from my perspective, it looks like I should open a new issue, as it is still not resolved.

  25. SomeoneSerge commented on Feb 10, 2024

    @SomeoneSerge
    Contributor

    @Ashvith10 yes, your issue is different; it's not clear to me yet if there's anything to "fix" about it, but do consider opening an issue under the Nixpkgs repo regarding impure GIO libraries and libstdc++ mismatches

    Also consider notifying Guix maintainers

  26. transferred this issue fromNixOS/nixon Feb 10, 2024
  27. changed the title [-]Nix Package Manager on Arch Linux: "`GLIBC_2.38' not found" Error[/-] [+]hello: "`GLIBC_2.38' not found" when using LD_PRELOAD with the host system's libstdc++ (higher than nixpkgs')[/+] on Feb 13, 2024
  28. SomeoneSerge commented on Feb 13, 2024

    @SomeoneSerge
    Contributor

    @Brogolem35 I updated the title to reflect how I understood the problem from your later comments. As mentioned above, I think this is a "wontfix" case. Thank you for reporting this, however, because this will help map the space of edge-cases and navigate people who encounter related errors

    With that in mind, I'm closing the issue. Feel free to reopen if you think I misunderstood anything

  29. added a commit that references this issue on Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions