BUG with dlmopen on Tumbleweed - symbol lookup error: /lib64/libnss_compat.so.2: undefined symbol: _nss_compat_endaliasent
I'm facing a strange problem with dlmopen() on Tumbleweed, FC34 and Ubuntu 21.04. The dlopen() functions work fine though. The problem doesn't happen on Leap 42.3 and all debian versions. The workaround is to set the LD_DEBUG environment variable. The other work around is to modify /etc/nsswitch.conf to not use only files. This issue was first reported on 24 Mar 2021 by someone. I too have reported multiple conditions under which the bug occurs and it still continues. This is an upstream issue but causing issues for multiple distributions downstream. https://sourceware.org/bugzilla/show_bug.cgi?id=27646 Any application that uses dlmopen() and calls any of the getpwent, getgrent, getaliasent, etc either segfault or give error on missing libnss symbols. It is trivial to simulate the issue. The below code snippets foo.c and test.c exploits the issue. cat <<EOF>foo.c #include <stdio.h> #include <pwd.h> void bar1() { struct passwd *pw; pw = getpwent(); if (pw) printf("%s\n", pw->pw_name); } EOF cat <<EOF>test.c #define _GNU_SOURCE #include <dlfcn.h> #include <stdio.h> int main(int argc, char **argv) { void *handle; int (*func) (); if (!(handle = dlmopen(LM_ID_NEWLM, "./libfoo.so", RTLD_NOW))) { perror("dlmopen"); return 1; } func = dlsym(handle, "bar1"); (*func)(); return 0; } EOF # On Tumbleweed gcc -fPIC -shared foo.c -o libfoo.so gcc test.c -o test -ldl ./test ./test: symbol lookup error: /lib64/libnss_compat.so.2: undefined symbol: _nss_compat_endaliasent # setting LD_DEBUG=unused fixes the issue env LD_DEBUG=unused ./test root # On Fedora 34 gcc -fPIC -shared foo.c -o libfoo.so gcc test.c -o test -ldl ./test Segmentation fault (core dumped) echo This command will not segfault env LD_DEBUG=unused ./test root # On Ubuntu 21.04 gcc -fPIC -shared foo.c -o libfoo.so gcc test.c -o test -ldl ./test ./test: symbol lookup error: /lib/x86_64-linux-gnu/libnss_files.so.2: undefined symbol: _nss_files_getcanonname_r # setting LD_DEBUG=unused fixes the issue env LD_DEBUG=unused ./test root -- Regards Manvendra - http://www.indimail.org GPG Pub Key http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC7CBC760014D250C
Am Dienstag, 31. August 2021, 14:12:00 CEST schrieb Manvendra Bhangui:
I'm facing a strange problem with dlmopen() on Tumbleweed, FC34 and Ubuntu 21.04. The dlopen() functions work fine though. The problem doesn't happen on Leap 42.3 and all debian versions. The workaround is to set the LD_DEBUG environment variable. The other work around is to modify /etc/nsswitch.conf to not use only files. This issue was first reported on 24 Mar 2021 by someone. I too have reported multiple conditions under which the bug occurs and it still continues. This is an upstream issue but causing issues for multiple distributions downstream.
Interesting.
Any application that uses dlmopen() and calls any of the getpwent, getgrent, getaliasent, etc either segfault or give error on missing libnss symbols. It is trivial to simulate the issue. The below code snippets foo.c and test.c exploits the issue.
cat <<EOF>foo.c #include <stdio.h> #include <pwd.h> void bar1() { struct passwd *pw; pw = getpwent(); if (pw) printf("%s\n", pw->pw_name); } EOF cat <<EOF>test.c #define _GNU_SOURCE #include <dlfcn.h> #include <stdio.h> int main(int argc, char **argv) { void *handle; int (*func) ();
if (!(handle = dlmopen(LM_ID_NEWLM, "./libfoo.so", RTLD_NOW))) { perror("dlmopen"); return 1; } func = dlsym(handle, "bar1"); (*func)(); return 0; } EOF
# On Tumbleweed gcc -fPIC -shared foo.c -o libfoo.so gcc test.c -o test -ldl ./test ./test: symbol lookup error: /lib64/libnss_compat.so.2: undefined symbol: _nss_compat_endaliasent # setting LD_DEBUG=unused fixes the issue env LD_DEBUG=unused ./test root
Well, not here ~> LD_DEBUG=unused ./test ./test: error while loading shared libraries: libnss_nis.so.2: cannot open shared object file: No such file or directory neither as a user nor root, but I'm using sss on this system. Have you opened an issue on https://bugzilla.opensuse.org already? Cheers, Pete
On Tue, 31 Aug 2021 at 18:50, Hans-Peter Jansen <hpj@urpla.net> wrote:
Well, not here
~> LD_DEBUG=unused ./test ./test: error while loading shared libraries: libnss_nis.so.2: cannot open shared object file: No such file or directory
Ok. you are missing libnss_nss.so.2 zypper in libnss_nis2
neither as a user nor root, but I'm using sss on this system.
Have you opened an issue on https://bugzilla.opensuse.org already?
No. Thanks for the pointer. Will open the issue there. I wasn't sure where to report the bug
Am Dienstag, 31. August 2021, 15:37:07 CEST schrieb Manvendra Bhangui:
On Tue, 31 Aug 2021 at 18:50, Hans-Peter Jansen <hpj@urpla.net> wrote:
Well, not here
~> LD_DEBUG=unused ./test ./test: error while loading shared libraries: libnss_nis.so.2: cannot open shared object file: No such file or directory
Ok. you are missing libnss_nss.so.2
zypper in libnss_nis2
Okay, given, I have some nis entries on /etc/nsswitch.conf, this points to some dependency issues, and the extended version enumerates all users using the LD_DEBUG workaround: cat <<EOF>foo.c #include <stdio.h> #include <pwd.h> void bar1() { struct passwd *pw = NULL; while (1) { pw = getpwent(); if (pw) printf("%s\n", pw->pw_name); else break; } }
neither as a user nor root, but I'm using sss on this system.
Have you opened an issue on https://bugzilla.opensuse.org already?
No. Thanks for the pointer. Will open the issue there. I wasn't sure where to report the bug
Post the bug id here, please. I would like to follow this issue. Cheers, Pete
On Tue, 31 Aug 2021 at 19:31, Hans-Peter Jansen <hpj@urpla.net> wrote:
Okay, given, I have some nis entries on /etc/nsswitch.conf, this points to some dependency issues, and the extended version enumerates all users using the LD_DEBUG workaround:
Ok.
cat <<EOF>foo.c #include <stdio.h> #include <pwd.h> void bar1() { struct passwd *pw = NULL; while (1) { pw = getpwent(); if (pw) printf("%s\n", pw->pw_name); else break; } }
Great.
Post the bug id here, please. I would like to follow this issue.
Bug id 1190012 https://bugzilla.opensuse.org/show_bug.cgi?id=1190012 -- Regards Manvendra - http://www.indimail.org GPG Pub Key http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC7CBC760014D250C
On Tue, 31 Aug 2021 at 18:50, Hans-Peter Jansen <hpj@urpla.net> wrote:
Well, not here
~> LD_DEBUG=unused ./test ./test: error while loading shared libraries: libnss_nis.so.2: cannot open shared object file: No such file or directory
neither as a user nor root, but I'm using sss on this system.
FC34 uses sss by default (in /etc./nsswitch.conf) and using sss causes segfault. I think you will get it too once you install libnss_nis2 package.
Have you opened an issue on https://bugzilla.opensuse.org already?
Just opened it https://bugzilla.opensuse.org/show_bug.cgi?id=1190012 -- Regards Manvendra - http://www.indimail.org GPG Pub Key http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC7CBC760014D250C
participants (2)
-
Hans-Peter Jansen
-
Manvendra Bhangui