On a linux system (ubuntu 20), there is a shared library that must be preloaded for each program when the program starts. The path to this library is written in /etc/ld.so.preload
. The library itself (named hooks.so
) is located in the /usr/lib/libsToPreload/
directory.
I noticed that when any applications installed via snap are launched, errors from the dynamic linker are printed, stating that /usr/lib/libsToPreload/hooks.so
cannot be preloaded (for example for pycharm-community snap):
ibse@ibse-desktop:~$ sudo snap install pycharm-community --classic
pycharm-community 2022.3.1 from jetbrains✓ installed
ibse@ibse-desktop:~$ pycharm-community
ERROR: ld.so: object '/usr/lib/libsToPreload/hooks.so' from /etc/ld.so.preload cannot be preloaded (failed to map segment from shared object): ignored.
...
As I managed to understand reading the snap documentation, this is because the file /usr/lib/libsToPreload/hooks.so
is not visible from the sandbox where the application is launched. But what is unclear is why then the /etc/ld.so.preload
file is visible from the sandbox. It turns out that the linker sees the contents of /etc/ld.so.preload
, tries to load it, but does not see /usr/lib/libsToPreload/hooks.so
and prints errors. It turns out that one part of the files (the one where /etc/ld.so.preload
) from the host file system is shared with the sandbox, and the other (the one where /usr/lib/libsToPreload/hooks.so
) is not? If so, can I as a user manage this? For example, to make /etc/ld.so.preload
not visible from the sandbox, as well as /usr/lib/libsToPreload/hooks.so
so that the linker would not try to preload anything.
The error is not critical and pycharm is successfully launched without the library written to /etc/ld.so.preload
, but it is necessary that these errors are not printed every time a snap application is launched. If I see the problem correctly, I need to ensure that either both files /etc/ld.so.preload
and /usr/lib/libsToPreload/hooks.so
are visible from the sandbox or both are invisible. Not so that one file is visible, and the second is not