Skip to content

libredirect on non-NixOS #29064

Closed
Closed

Description

Issue description

Steps to reproduce

When using libredirect on non-NixOS distro, e.g. Debian 9, LD_PRELOAD is propagated, so if wrapped application runs some system binary, there is an error:

sh: relocation error: /nix/store/sgjc1147vi5hd57ck9xgck5xjkydg5lz-glibc-2.25/lib/libdl.so.2: symbol _dl_catch_error, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference

Is there a way to fix that?

Technical details

  • System: (NixOS: nixos-version, Ubuntu/Fedora: lsb_release -a, ...)
  • Nix version: (run nix-env --version)
  • Nixpkgs version: (run nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion)
  • Sandboxing enabled: (run grep build-use-sandbox /etc/nix/nix.conf)

Activity

  1. vcunat commented on Sep 7, 2017

    @vcunat
    Member

    That confuses me a bit. I thought the main point of libredirect is to avoid using LD_PRELOAD.

  2. vcunat commented on Sep 7, 2017

    @vcunat
    Member

    I'm sorry, I confused those :-/

    It certainly is possible to add a new variable for this. I wonder if it's a good idea; I don't see any caveats yet.

  3. added
    6.topic: non-nixos
    on Sep 7, 2017
  4. Mic92 commented on Sep 7, 2017

    @Mic92
    Member

    One way to avoid this, is to unset LD_LIBRARY in the libredirect code.
    So it will be only used by the actual process will pick it up.

  5. dezgeg commented on Sep 7, 2017

    @dezgeg
    Contributor

    Well, it's a problem on NixOS as well that the redirect leaks to all possible child processes.

    Maybe libredirect could remove itself from LD_PRELOAD on startup.

  6. vcunat commented on Sep 7, 2017

    @vcunat
    Member

    I suppose this depends on the particular use case. I can imagine you to want to "sandbox" all child processes as well, because they are e.g. just parts of the same application.

  7. vcunat commented on Sep 7, 2017

    @vcunat
    Member

    For maximal flexibility, there could e.g. be a build-time parameter to libredirect – a list of paths, and it would deactivate itself when in a process outside those subtrees. But it seems useless to implement such a sledge-hammer until we know at least some particular use case.

  8. dezgeg commented on Sep 7, 2017

    @dezgeg
    Contributor

    There have been occassional complaints on IRC about the Teamspeak client (which uses libredirect) being unable to open links in Chromium because the inherited libredirect causes Chromium to crash.

  9. knedlsepp commented on Sep 27, 2017

    @knedlsepp
    Member

    Currently having this problem as well:

    • Installed sublime3 and ctags.
    • Installed the CTags package inside sublime.
    • Try to run ctags from within sublime leads to:
    sort: relocation error: /nix/store/bwax7l3946zn3l806727sd1fk8ssjgpv-glibc-2.25-49/lib/libdl.so.2: symbol _dl_catch_error, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
    ctags: cannot sort tag file : No such file or directory
    

    I've worked around this issue by installing nixpkgs.coreutils, to get the sort command from nixpkgs.

  10. Mic92 commented on Sep 27, 2017

    @Mic92
    Member

    I just tested and unsetenv("LD_PRELOAD"); does not work reliable: https://stackoverflow.com/questions/3275015/ld-preload-affects-new-child-even-after-unsetenvld-preload
    Maybe wrapping exec and do the cleanup should work.

  11. dezgeg commented on Sep 27, 2017

    @dezgeg
    Contributor

    It might be worth asking the glibc people if they'd be willing to have an option like ${glibc}/lib/ld-linux.so.2 --preload implemented in the dynamic linker similar to the --library-path option they have. Then instead of adding an environment variable, makeWrapper could prefix the command with an explicit call to the linker.

    (I don't know offhand if this would break other things by e.g. affecting argv[0] or /proc/self/exe...)

  12. ghost closed this as completedon Sep 20, 2019
  13. lf- commented on Aug 19, 2021

    @lf-
    Member

    If anyone is hitting this with Haskell stack on non-NixOS distros, just use the nix integration for Stack:

    Put:

    nix:
      enable: true
    

    in your ~/.stack/config.yaml or project specific stack.yaml and you're done.

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

    6.topic: non-nixos

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions