Problem starting chromium
Starting chromium ends with "undefined symbol".
To Reproduce
Steps to reproduce the behavior:
$ nix run nixpkgs.chromium -c chromium
grep: symbol lookup error: grep: undefined symbol: pcre_jit_stack_alloc
/nix/store/ypm0s05hl2cxicy5nwgqh96nrp0cjabq-chromium-unwrapped-76.0.3809.100/libexec/chromium/chromium: symbol lookup error: /nix/store/hx3mk2bnjp4vlqfwzmycvdq3hh6vf71j-libselinux-2.7/lib/libselinux.so.1: undefined symbol: pcre_free_study
Expected behavior
I would expect chromium to start.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
If I check what the actual binary is from readlink -f $(which chromium), I can start the browser, so the problem is one of the environment variables.
I tried commenting out the exports and I could "fix" the problem locally by commenting out the LD_LIBRARY_PATH.
Metadata
Please run nix run nixpkgs.nix-info -c nix-info -m and paste the result.
"x86_64-linux"Linux 5.2.9, NixOS, 19.09pre189585.1412af4b2cf (Loris)yesnonix-env (Nix) 2.2.2"home-manager, nixos-19.09pre189585.1412af4b2cf, unstable-19.09pre186574.88d9f776091"""/nix/var/nix/profiles/per-user/root/channels/nixosMaintainer information:
# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
I can't reproduce this by running nix run nixpkgs.chromium -c chromium on NixOS master.
The error message indicates that this is a problem with grep. Does grep work for you elsewhere?
Are you still seeing this? Do you have any relevant system configuration or bashrc/zshrc?
Does nix-store --verify --check-contents complain about anything?
Yeah, grep works elsewhere. And even chromium starts, if I copy the wrapper script to my home, modify the LD_LIBRARY_PATH line and only then call it.
nix-store --verify --check-contents was clean.
I tried within a "clean" bash shell (I usually use zsh so the bash config should be somewhat empty, unless some transient derivation modifies it)
So I figured this out, I'll write a patch later on if nobody else does it first.
For context, the wrapper script is given below.
The relevant part is the export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:" which ends up setting up the path as just a colon :. You might think that this is a safe default, but this is actually a corner case on how the paths are resolved. According to this a path ending with a colon means that the current working directory is added to the path.
In my case, I have a libpcre.so.1 in my home directory (for whatever reason), which was selected over the system libraries since by default the CWD is HOME.
The fix would be to not do export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:${libPath}", but have the colon conditional based on whether the ${libPath} is empty
#! /nix/store/506nnycf7nk22x7n07mjjjl2g8nifpda-bash-4.4-p23/bin/bash -e
if [ -x "/run/wrappers/bin/__chromium-suid-sandbox" ]
then
export CHROME_DEVEL_SANDBOX="/run/wrappers/bin/__chromium-suid-sandbox"
else
export CHROME_DEVEL_SANDBOX="/nix/store/yrdbib5yhm7m5bpca75g2l97143bskla-chromium-78.0.3904.70-sandbox/bin/__chromium-suid-sandbox"
fi
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:"
# libredirect causes chromium to deadlock on startup
export LD_PRELOAD="$(echo -n "$LD_PRELOAD" | tr ':' '\n' | grep -v /lib/libredirect\\.so$ | tr '\n' ':')"
export XDG_DATA_DIRS=/nix/store/m6q8c22xfldzfsr8xizzgbfjh9wm70bk-cups-2.2.12/share:/nix/store/gy3pcnn4j7iqhhmk2fyafk5krl3psn9i-gtk+3-3.24.10/share:/nix/store/4xyyscml9mg2jifqal1z7q7nngkwrdaw-adwaita-icon-theme-3.32.0/share:/nix/store/6ggm104z9dnx0m0lbqcqmdqswh2gn01a-hicolor-icon-theme-0.17/share:/nix/store/m6q8c22xfldzfsr8xizzgbfjh9wm70bk-cups-2.2.12/share:/nix/store/gy3pcnn4j7iqhhmk2fyafk5krl3psn9i-gtk+3-3.24.10/share:/nix/store/4xyyscml9mg2jifqal1z7q7nngkwrdaw-adwaita-icon-theme-3.32.0/share:/nix/store/6ggm104z9dnx0m0lbqcqmdqswh2gn01a-hicolor-icon-theme-0.17/share:/nix/store/sggza6377wfflqgzflhrfchgay6a5clf-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0:/nix/store/gy3pcnn4j7iqhhmk2fyafk5krl3psn9i-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10:/nix/store/sggza6377wfflqgzflhrfchgay6a5clf-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0:/nix/store/gy3pcnn4j7iqhhmk2fyafk5krl3psn9i-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS
exec "/nix/store/gam17vhrh1nbf02bpa29b65c3h1f1m4m-chromium-unwrapped-78.0.3904.70/libexec/chromium/chromium" "${extraFlagsArray[@]}" "$@"
Thanks for investigating, I have reproduced this with:
# touch libpcre.so.1
# chmod +x libpcre.so.1
# chromium --user-data-dir=/tmp/deleteme
grep: error while loading shared libraries: libpcre.so.1: file too short
/nix/store/pzx588yd5799gc5f9sysh41xzqf7vd4x-chromium-unwrapped-76.0.3809.87/libexec/chromium/chromium: error while loading shared libraries: libpcre.so.1: file too short
and I'll have a PR soon.
Great! Thank you
Most helpful comment
So I figured this out, I'll write a patch later on if nobody else does it first.
For context, the wrapper script is given below.
The relevant part is the
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:"which ends up setting up the path as just a colon:. You might think that this is a safe default, but this is actually a corner case on how the paths are resolved. According to this a path ending with a colon means that the current working directory is added to the path.In my case, I have a
libpcre.so.1in my home directory (for whatever reason), which was selected over the system libraries since by default the CWD is HOME.The fix would be to not do
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:${libPath}", but have the colon conditional based on whether the${libPath}is empty