Skip Menu |
Report information
Id: 132351
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: asper [at] tagan.ru
Cc:
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: High
Type: core
Perl Version: 5.24.3
Fixed In: (no value)



Subject: perl function getgrent not worked with libnss
From: Михаил Манерко <asper [...] tagan.ru>
Date: Mon, 23 Oct 2017 13:39:51 +0300
To: perlbug [...] perl.org
Download (untitled) / with headers
text/plain 7.9k

This is a bug report for perl from asper@tagan.ru,
generated with the help of perlbug 1.40 running under perl 5.24.3.


-----------------------------------------------------------------
[Please describe your issue here]
perl function getgrent not worked in perl higer 5.20.x
if enabled sys-auth/libnss-pgsql library
if the groups are taken from the file, then everything is fine, and if the groups are taken from the database, then the getgent function hangs

I prepared a simple test script to check this
perl -e 'while ($a =getgrent) {print $a . "\n";}'
this script hangs if it is enabled to take groups and users from the database, this error is absent in the version 5.20 perl and below


my nsswitch config file
cat /etc/nsswitch.conf 
# /etc/nsswitch.conf:
# $Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/nsswitch.conf,v 1.1 2006/09/29 23:52:23 vapier Exp $

group: pgsql files
passwd: pgsql files
shadow: pgsql files

#passwd:      compat
#shadow:      compat
#group:       compat

# passwd:    db files nis
# shadow:    db files nis
# group:     db files nis

hosts:       files dns
networks:    files dns

services:    db files
protocols:   db files
rpc:         db files
ethers:      db files
netmasks:    files
netgroup:    files
bootparams:  files

automount:   files
aliases:     files

system utils
getent group - work fine


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=high
---
Site configuration information for perl 5.24.3:

Configured by Gentoo at Fri Oct 20 13:19:22 MSK 2017.

Summary of my perl5 (revision 5 version 24 subversion 3) configuration:
   
  Platform:
    osname=linux, osvers=4.0.9-gentoo, archname=x86_64-linux
    uname='linux gbase 4.0.9-gentoo #1 smp thu may 26 12:49:22 msk 2016 x86_64 qemu virtual cpu version 2.3.0 authenticamd gnulinux '
    config_args='-des -Dinstallprefix=/usr -Dinstallusrbinperl=n -Di_ndbm -Di_gdbm -Di_db -DDEBUGGING=none -Dinc_version_list=5.24.2/x86_64-linux 5.24.2 5.24.1/x86_64-linux 5.24.1 5.24.0/x86_64-linux 5.24.0  -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Dnoextensions=ODBM_File -Duseshrplib -Darchname=x86_64-linux -Dcc=x86_64-pc-linux-gnu-gcc -Doptimize=-O2 -pipe -march=x86-64 -mtune=generic -Dldflags=-Wl,-O1 -Wl,--as-needed -Dprefix=/usr -Dsiteprefix=/usr/local -Dvendorprefix=/usr -Dscriptdir=/usr/bin -Dprivlib=/usr/lib64/perl5/5.24.3 -Darchlib=/usr/lib64/perl5/5.24.3/x86_64-linux -Dsitelib=/usr/local/lib64/perl5/5.24.3 -Dsitearch=/usr/local/lib64/perl5/5.24.3/x86_64-linux -Dvendorlib=/usr/lib64/perl5/vendor_perl/5.24.3 -Dvendorarch=/usr/lib64/perl5/vendor_perl/5.24.3/x86_64-linux -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dvendorman1dir=/usr/share/man/man1 -Dvendorman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dlibperl=libperl.so.5.24.3 -Dlocincpth=/usr/include  -Dglibpth=/lib64 /usr/lib64  -Duselargefiles -Dd_semctl_semun -Dcf_by=Gentoo -Dmyhostname=localhost -Dperladmin=root@localhost -Ud_csh -Dsh=/bin/sh -Dtargetsh=/bin/sh -Uusenm -Di_ndbm -Di_gdbm -Di_db -DDEBUGGING=none -Dinc_version_list=5.24.2/x86_64-linux 5.24.2 5.24.1/x86_64-linux 5.24.1 5.24.0/x86_64-linux 5.24.0  -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Dnoextensions=ODBM_File'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='x86_64-pc-linux-gnu-gcc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -pipe -march=x86-64 -mtune=generic',
    cppflags='-fwrapv -fno-strict-aliasing -pipe'
    ccversion='', gccversion='4.9.3', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='x86_64-pc-linux-gnu-gcc', ldflags ='-Wl,-O1 -Wl,--as-needed'
    libpth=/usr/local/lib64 /lib64 /usr/lib64 /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include-fixed /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.23.so, so=so, useshrplib=true, libperl=libperl.so.5.24.3
    gnulibc_version='2.23'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -pipe -march=x86-64 -mtune=generic -Wl,-O1 -Wl,--as-needed'

Locally applied patches:
    gentoo/hints_hpux - Fix hpux hints
    gentoo/aix_soname - aix gcc detection and shared library soname support
    gentoo/EUMM-RUNPATH - https://bugs.gentoo.org/105054 cpan/ExtUtils-MakeMaker: drop $PORTAGE_TMPDIR from LD_RUN_PATH
    gentoo/config_over - Remove -rpath and append LDFLAGS to lddlflags
    gentoo/opensolaris_headers - Add headers for opensolaris
    gentoo/patchlevel - List packaged patches for perl-5.24.3(#1) in patchlevel.h
    gentoo/cleanup-paths - Cleanup PATH and shrpenv
    gentoo/enc2xs - Tweak enc2xs to follow symlinks and ignore missing @INC directories.
    gentoo/darwin-cc-ld - https://bugs.gentoo.org/297751 darwin: Use $CC to link
    gentoo/cpan_definstalldirs - Provide a sensible INSTALLDIRS default for modules installed from CPAN.
    gentoo/interix - Fix interix hints
    gentoo/create_libperl_soname - https://bugs.gentoo.org/286840 Set libperl soname
    gentoo/mod_paths - Add /etc/perl to @INC
    gentoo/EUMM_perllocalpod - cpan/ExtUtils-MakeMaker: remove targets that generate perllocal.pod
    gentoo/drop_fstack_protector - https://bugs.gentoo.org/348557 Don't force -fstack-protector on everyone
    gentoo/usr_local - Configure: Don't include sources in /usr/local/ for compiling perl
    gentoo/D-SHA-CFLAGS - https://bugs.gentoo.org/506818 Do not set custom CFLAGS in cpan/Digest-SHA
    gentoo/io_socket_ip_tests - cpan/IO-Socket-IP: Disable network tests
    gentoo/cygwin-libperl - Cygwin: avoid libperl.dll.dll.a
    gentoo/tests - Fixup EUMM perlocal.pod tests and customised SHA1s
    gentoo/zlib-1.2.9-backported-fixes - [rt#119762] Compress-Raw-Zlib: backport zlib 1.2.9+ fixes from upstream 2.073
    debian/cpan-missing-site-dirs - Fix CPAN::FirstTime defaults with nonexisting site dirs if a parent is writable
    debian/makemaker-pasthru - Pass LD settings through to subdirectories
    fixes/memoize_storable_nstore - [rt.cpan.org #77790] Memoize::Storable: respect 'nstore' option not respected
    fixes/podman-pipe - Better errors for man pages from standard input
    fixes/respect_umask - Respect umask during installation
    fixes/net_smtp_docs - [rt.cpan.org #36038] Document the Net::SMTP 'Port' option
    fixes/document_makemaker_ccflags - [rt.cpan.org #68613] Document that CCFLAGS should include $Config{ccflags}
    fixes/parallel-manisort.patch - Fix parallel building

---
@INC for perl 5.24.3:
    /etc/perl
    /usr/local/lib64/perl5/5.24.3/x86_64-linux
    /usr/local/lib64/perl5/5.24.3
    /usr/lib64/perl5/vendor_perl/5.24.3/x86_64-linux
    /usr/lib64/perl5/vendor_perl/5.24.3
    /usr/local/lib64/perl5
    /usr/lib64/perl5/vendor_perl
    /usr/lib64/perl5/5.24.3/x86_64-linux
    /usr/lib64/perl5/5.24.3

---
Environment for perl 5.24.3:
    HOME=/root
    LANG=ru_RU.UTF-8
    LANGUAGE (unset)
    LC_ALL=
    LC_COLLATE=C
    LC_MESSAGES=C
    LC_TIME=C
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

-- 
Regards,
Michael A. Manerko

Megalink Company, Engineer
318, Chehova street, Taganrog, Russia, 347932
tel work: +7 8634 431431 (ext 159)
tel mobile: +7 999 6939428
sip: 159@tagan.ru
www.tagan.ru
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.6k
On Mon, 23 Oct 2017 10:55:44 GMT, asper@tagan.ru wrote: Show quoted text
> This is a bug report for perl from asper@tagan.ru, > generated with the help of perlbug 1.40 running under perl 5.24.3. > > > ----------------------------------------------------------------- > [Please describe your issue here] > perl function getgrent not worked in perl higer 5.20.x > if enabled sys-auth/libnss-pgsql library > if the groups are taken from the file, then everything is fine, and if > the groups are taken from the database, then the getgent function > hangs > > I prepared a simple test script to check this > perl -e 'while ($a =getgrent) {print $a . "\n";}' > this script hangs if it is enabled to take groups and users from the > database, this error is absent in the version 5.20 perl and below >
Do you get any output at all if it is enable to take groups and users from the database? Show quoted text
> > my nsswitch config file > cat /etc/nsswitch.conf > # /etc/nsswitch.conf: > # $Header: > /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/nsswitch.conf,v 1.1 > 2006/09/29 23:52:23 vapier Exp $ > > group: pgsql files > passwd: pgsql files > shadow: pgsql files > > #passwd: compat > #shadow: compat > #group: compat > > # passwd: db files nis > # shadow: db files nis > # group: db files nis > > hosts: files dns > networks: files dns > > services: db files > protocols: db files > rpc: db files > ethers: db files > netmasks: files > netgroup: files > bootparams: files > > automount: files > aliases: files > > system utils > getent group - work fine > >
-- James E Keenan (jkeenan@cpan.org)
From: Михаил Манерко <asper [...] tagan.ru>
Subject: Re: [perl #132351] perl function getgrent not worked with libnss
Date: Tue, 24 Oct 2017 10:33:32 +0300
To: perlbug-followup [...] perl.org
Download (untitled) / with headers
text/plain 2.2k
23.10.2017 23:26, James E Keenan via RT пишет: Show quoted text
> On Mon, 23 Oct 2017 10:55:44 GMT, asper@tagan.ru wrote:
>> This is a bug report for perl from asper@tagan.ru, >> generated with the help of perlbug 1.40 running under perl 5.24.3. >> >> >> ----------------------------------------------------------------- >> [Please describe your issue here] >> perl function getgrent not worked in perl higer 5.20.x >> if enabled sys-auth/libnss-pgsql library >> if the groups are taken from the file, then everything is fine, and if >> the groups are taken from the database, then the getgent function >> hangs >> >> I prepared a simple test script to check this >> perl -e 'while ($a =getgrent) {print $a . "\n";}' >> this script hangs if it is enabled to take groups and users from the >> database, this error is absent in the version 5.20 perl and below >>
> Do you get any output at all if it is enable to take groups and users from the database?
There is no output, the script hangs (infinite loop?) The execution of the script can be interrupted by ^С. We use the x2go server, when upgrading the pearl above 5.20 clients can not connect to the server. Traced the function on which the client connection hangs - it turned out to be a gettent. After that, I checked on other versions of perl 5.22, 5.24, 5.26 on all this function with the enabled livens hangs. Show quoted text
>> my nsswitch config file >> cat /etc/nsswitch.conf >> # /etc/nsswitch.conf: >> # $Header: >> /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/nsswitch.conf,v 1.1 >> 2006/09/29 23:52:23 vapier Exp $ >> >> group: pgsql files >> passwd: pgsql files >> shadow: pgsql files >> >> #passwd: compat >> #shadow: compat >> #group: compat >> >> # passwd: db files nis >> # shadow: db files nis >> # group: db files nis >> >> hosts: files dns >> networks: files dns >> >> services: db files >> protocols: db files >> rpc: db files >> ethers: db files >> netmasks: files >> netgroup: files >> bootparams: files >> >> automount: files >> aliases: files >> >> system utils >> getent group - work fine >> >>
>
-- Regards, Michael A. Manerko Megalink Company, Engineer 318, Chehova street, Taganrog, Russia, 347932 tel work: +7 8634 431431 (ext 159) tel mobile: +7 999 6939428 sip: 159@tagan.ru www.tagan.ru
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 2.7k
On Thu, 26 Oct 2017 03:52:19 GMT, asper@tagan.ru wrote: Show quoted text
> 23.10.2017 23:26, James E Keenan via RT пишет:
> > On Mon, 23 Oct 2017 10:55:44 GMT, asper@tagan.ru wrote:
> >> This is a bug report for perl from asper@tagan.ru, > >> generated with the help of perlbug 1.40 running under perl 5.24.3. > >> > >> > >> ----------------------------------------------------------------- > >> [Please describe your issue here] > >> perl function getgrent not worked in perl higer 5.20.x > >> if enabled sys-auth/libnss-pgsql library > >> if the groups are taken from the file, then everything is fine, and > >> if > >> the groups are taken from the database, then the getgent function > >> hangs > >> > >> I prepared a simple test script to check this > >> perl -e 'while ($a =getgrent) {print $a . "\n";}' > >> this script hangs if it is enabled to take groups and users from the > >> database, this error is absent in the version 5.20 perl and below > >>
> > Do you get any output at all if it is enable to take groups and users > > from the database?
> There is no output, the script hangs (infinite loop?) > The execution of the script can be interrupted by ^С. > > We use the x2go server, when upgrading the pearl above 5.20 clients > can not connect to the server. > Traced the function on which the client connection hangs - it turned > out to be a gettent. > After that, I checked on other versions of perl 5.22, 5.24, 5.26 on > all this function with the enabled livens hangs. >
> >> my nsswitch config file > >> cat /etc/nsswitch.conf > >> # /etc/nsswitch.conf: > >> # $Header: > >> /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/nsswitch.conf,v > >> 1.1 > >> 2006/09/29 23:52:23 vapier Exp $ > >> > >> group: pgsql files > >> passwd: pgsql files > >> shadow: pgsql files > >> > >> #passwd: compat > >> #shadow: compat > >> #group: compat > >> > >> # passwd: db files nis > >> # shadow: db files nis > >> # group: db files nis > >> > >> hosts: files dns > >> networks: files dns > >> > >> services: db files > >> protocols: db files > >> rpc: db files > >> ethers: db files > >> netmasks: files > >> netgroup: files > >> bootparams: files > >> > >> automount: files > >> aliases: files > >> > >> system utils > >> getent group - work fine > >> > >>
> >
This is going to be difficult for us to debug because there are several factors --- the x2go server, the libnss-pgsql library, the use of a database for NSS -- which are outside the scope of the Perl 5 core distribution and which will be difficult for our readers to emulate. So I am grasping at straws here. Do you experience the same problem if you use the User::grent module included in the core distribution? (see attachment) Thank you very much. -- James E Keenan (jkeenan@cpan.org)
Subject: usergrent.pl
Download usergrent.pl
text/x-perl 206b
# perl use strict; use warnings; use 5.10.1; use User::grent; while (my $y = getgrent()) { say join('|' => ( $y->name, $y->passwd, $y->gid, "@{$y->members}", ) ); }
Subject: Re: [perl #132351] perl function getgrent not worked with libnss
From: Михаил Манерко <asper [...] tagan.ru>
Date: Fri, 27 Oct 2017 17:41:05 +0300
To: perlbug-followup [...] perl.org
Download (untitled) / with headers
text/plain 3.2k
using the User::grent module, the grant also causes a hang. I ran the test script that you sent - it hangs. To verify, you really need a library of libnss and a postgres database x2go server is not needed I also checked this script in ubuntu with the included libnsss library there, too, hangs 27.10.2017 16:41, James E Keenan via RT пишет: Show quoted text
> On Thu, 26 Oct 2017 03:52:19 GMT, asper@tagan.ru wrote:
>> 23.10.2017 23:26, James E Keenan via RT пишет:
>>> On Mon, 23 Oct 2017 10:55:44 GMT, asper@tagan.ru wrote:
>>>> This is a bug report for perl from asper@tagan.ru, >>>> generated with the help of perlbug 1.40 running under perl 5.24.3. >>>> >>>> >>>> ----------------------------------------------------------------- >>>> [Please describe your issue here] >>>> perl function getgrent not worked in perl higer 5.20.x >>>> if enabled sys-auth/libnss-pgsql library >>>> if the groups are taken from the file, then everything is fine, and >>>> if >>>> the groups are taken from the database, then the getgent function >>>> hangs >>>> >>>> I prepared a simple test script to check this >>>> perl -e 'while ($a =getgrent) {print $a . "\n";}' >>>> this script hangs if it is enabled to take groups and users from the >>>> database, this error is absent in the version 5.20 perl and below >>>>
>>> Do you get any output at all if it is enable to take groups and users >>> from the database?
>> There is no output, the script hangs (infinite loop?) >> The execution of the script can be interrupted by ^С. >> >> We use the x2go server, when upgrading the pearl above 5.20 clients >> can not connect to the server. >> Traced the function on which the client connection hangs - it turned >> out to be a gettent. >> After that, I checked on other versions of perl 5.22, 5.24, 5.26 on >> all this function with the enabled livens hangs. >>
>>>> my nsswitch config file >>>> cat /etc/nsswitch.conf >>>> # /etc/nsswitch.conf: >>>> # $Header: >>>> /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/nsswitch.conf,v >>>> 1.1 >>>> 2006/09/29 23:52:23 vapier Exp $ >>>> >>>> group: pgsql files >>>> passwd: pgsql files >>>> shadow: pgsql files >>>> >>>> #passwd: compat >>>> #shadow: compat >>>> #group: compat >>>> >>>> # passwd: db files nis >>>> # shadow: db files nis >>>> # group: db files nis >>>> >>>> hosts: files dns >>>> networks: files dns >>>> >>>> services: db files >>>> protocols: db files >>>> rpc: db files >>>> ethers: db files >>>> netmasks: files >>>> netgroup: files >>>> bootparams: files >>>> >>>> automount: files >>>> aliases: files >>>> >>>> system utils >>>> getent group - work fine >>>> >>>>
> This is going to be difficult for us to debug because there are several factors --- the x2go server, the libnss-pgsql library, the use of a database for NSS -- which are outside the scope of the Perl 5 core distribution and which will be difficult for our readers to emulate. > > So I am grasping at straws here. Do you experience the same problem if you use the User::grent module included in the core distribution? (see attachment) > > Thank you very much. >
-- Regards, Michael A. Manerko Megalink Company, Engineer 318, Chehova street, Taganrog, Russia, 347932 tel work: +7 8634 431431 (ext 159) tel mobile: +7 999 6939428 sip: 159@tagan.ru www.tagan.ru
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 787b
On Sat, 28 Oct 2017 22:25:19 GMT, asper@tagan.ru wrote: Show quoted text
> using the User::grent module, the grant also causes a hang. > > I ran the test script that you sent - it hangs. > > To verify, you really need a library of libnss and a postgres database > > x2go server is not needed > > I also checked this script in ubuntu with the included libnsss library > there, too, hangs >
Could you clarify what you mean exactly by that? Which script is "this script"? When you refer to "the included libnss library", are you referring, say, to libnss3? Or to something else? I ask this because if we can demonstrate a problem with libnss (of some sort) not connected to PostgreSQL, then we may have a better handle on the problem. Thank you very much. -- James E Keenan (jkeenan@cpan.org)
To: perlbug-followup [...] perl.org
Date: Mon, 30 Oct 2017 15:09:01 +0300
Subject: Re: [perl #132351] perl function getgrent not worked with libnss
From: Михаил Манерко <asper [...] tagan.ru>
Download (untitled) / with headers
text/plain 1.5k
Under the script, I meant perl -e 'while ($a =getgrent) {print $a . "\n";}' AND # perl use strict; use warnings; use 5.10.1; use User::grent; while (my $y = getgrent()) { say join('|' => ( $y->name, $y->passwd, $y->gid, "@{$y->members}", ) ); } I do not know how to get hung without a postgres database for testing, I tried to use another library nss-userfiles with it the function getgrent does not hang I am attaching two trace files. One trace of the execution of the perl script. The second system utility. 29.10.2017 03:40, James E Keenan via RT пишет: Show quoted text
> On Sat, 28 Oct 2017 22:25:19 GMT, asper@tagan.ru wrote:
>> using the User::grent module, the grant also causes a hang. >> >> I ran the test script that you sent - it hangs. >> >> To verify, you really need a library of libnss and a postgres database >> >> x2go server is not needed >> >> I also checked this script in ubuntu with the included libnsss library >> there, too, hangs >>
> Could you clarify what you mean exactly by that? Which script is "this script"? When you refer to "the included libnss library", are you referring, say, to libnss3? Or to something else? > > I ask this because if we can demonstrate a problem with libnss (of some sort) not connected to PostgreSQL, then we may have a better handle on the problem. > > Thank you very much. > > >
-- Regards, Michael A. Manerko Megalink Company, Engineer 318, Chehova street, Taganrog, Russia, 347932 tel work: +7 8634 431431 (ext 159) tel mobile: +7 999 6939428 sip: 159@tagan.ru www.tagan.ru
Download getent-group.txt
text/plain 26k

Message body is not shown because sender requested not to inline it.

Download perl-getgrent.txt
text/plain 12.7k

Message body is not shown because sender requested not to inline it.

From: Михаил Манерко <asper [...] tagan.ru>
Subject: Re: [perl #132351] perl function getgrent not worked with libnss
To: perlbug-followup [...] perl.org
Date: Wed, 1 Nov 2017 16:49:05 +0300
Download (untitled) / with headers
text/plain 2.1k
I want to inform you that I found a solution to the problem. I rebuilt in the debugging mode, glibc, linss-pgsgl, perl 5.24 and through the tracer found a function in which hangs. This is a function in the libnss_pgsqll library. after changing the lock type in a libnss_pgsql with MUTEX to RECURSIVE_MUTEX, the getgrent function stops hanging. however I still do not understand what changed in the perl after version 5.20 and caused the getgrent to hang 30.10.2017 15:09, Михаил Манерко пишет: Show quoted text
> Under the script, I meant > > perl -e 'while ($a =getgrent) {print $a . "\n";}' > > AND > > # perl > use strict; > use warnings; > use 5.10.1; > use User::grent; > > while (my $y = getgrent()) { > say join('|' => ( > $y->name, > $y->passwd, > $y->gid, > "@{$y->members}", > ) ); > } > > > I do not know how to get hung without a postgres database > > for testing, I tried to use another library nss-userfiles with it the function getgrent does not hang > > > I am attaching two trace files. One trace of the execution of the perl script. The second system utility. > > 29.10.2017 03:40, James E Keenan via RT пишет:
>> On Sat, 28 Oct 2017 22:25:19 GMT, asper@tagan.ru wrote:
>>> using the User::grent module, the grant also causes a hang. >>> >>> I ran the test script that you sent - it hangs. >>> >>> To verify, you really need a library of libnss and a postgres database >>> >>> x2go server is not needed >>> >>> I also checked this script in ubuntu with the included libnsss library >>> there, too, hangs >>>
>> Could you clarify what you mean exactly by that? Which script is "this script"? When you refer to "the included libnss library", are you referring, say, to libnss3? Or to something else? >> >> I ask this because if we can demonstrate a problem with libnss (of some sort) not connected to PostgreSQL, then we may have a better handle on the problem. >> >> Thank you very much. >> >> >>
-- Regards, Michael A. Manerko Megalink Company, Engineer 318, Chehova street, Taganrog, Russia, 347932 tel work: +7 8634 431431 (ext 159) tel mobile: +7 999 6939428 sip: 159@tagan.ru www.tagan.ru
From: James E Keenan <jkeenan [...] pobox.com>
Subject: Re: [perl #132351] perl function getgrent not worked with libnss
Date: Wed, 1 Nov 2017 11:30:43 -0400
To: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 2.4k
On 11/01/2017 09:49 AM, Михаил Манерко wrote: Show quoted text
> I want to inform you that I found a solution to the problem. > > I rebuilt in the debugging mode, glibc, linss-pgsgl, perl 5.24 and through the tracer found a function in which hangs. >
Would you be able to post that trace and your work-around? Even if we can't track down the perl problem it would be good for future reference in case someone with expertise in linss-pgsql stumbles upon this problem. Show quoted text
> This is a function in the libnss_pgsqll library. > > after changing the lock type in a libnss_pgsql with MUTEX to RECURSIVE_MUTEX, the getgrent function stops hanging. > > > however I still do not understand what changed in the perl after version 5.20 and caused the getgrent to hang >
Nor do I. I couldn't see any modifications to the source code for getgrent after 5.20 (though I may not have known every place to look). Show quoted text
> > 30.10.2017 15:09, Михаил Манерко пишет:
>> Under the script, I meant >> >> perl -e 'while ($a =getgrent) {print $a . "\n";}' >> >> AND >> >> # perl >> use strict; >> use warnings; >> use 5.10.1; >> use User::grent; >> >> while (my $y = getgrent()) { >> say join('|' => ( >> $y->name, >> $y->passwd, >> $y->gid, >> "@{$y->members}", >> ) ); >> } >> >> >> I do not know how to get hung without a postgres database >> >> for testing, I tried to use another library nss-userfiles with it the function getgrent does not hang >> >> >> I am attaching two trace files. One trace of the execution of the perl script. The second system utility. >> >> 29.10.2017 03:40, James E Keenan via RT пишет:
>>> On Sat, 28 Oct 2017 22:25:19 GMT, asper@tagan.ru wrote:
>>>> using the User::grent module, the grant also causes a hang. >>>> >>>> I ran the test script that you sent - it hangs. >>>> >>>> To verify, you really need a library of libnss and a postgres database >>>> >>>> x2go server is not needed >>>> >>>> I also checked this script in ubuntu with the included libnsss library >>>> there, too, hangs >>>>
>>> Could you clarify what you mean exactly by that? Which script is "this script"? When you refer to "the included libnss library", are you referring, say, to libnss3? Or to something else? >>> >>> I ask this because if we can demonstrate a problem with libnss (of some sort) not connected to PostgreSQL, then we may have a better handle on the problem. >>> >>> Thank you very much. >>> >>> >>>
>
Date: Thu, 2 Nov 2017 16:54:38 +1100
To: Михаил Манерко <asper [...] tagan.ru>
CC: perlbug-followup [...] perl.org
From: Tony Cook <tony [...] develop-help.com>
Subject: Re: [perl #132351] perl function getgrent not worked with libnss
Download (untitled) / with headers
text/plain 957b
On Wed, Nov 01, 2017 at 04:49:05PM +0300, Михаил Манерко wrote: Show quoted text
> I want to inform you that I found a solution to the problem. > > I rebuilt in the debugging mode, glibc, linss-pgsgl, perl 5.24 and through the tracer found a function in which hangs. > > This is a function in the libnss_pgsqll library. > > after changing the lock type in a libnss_pgsql with MUTEX to RECURSIVE_MUTEX, the getgrent function stops hanging. > > > however I still do not understand what changed in the perl after version 5.20 and caused the getgrent to hang
Is there any chance you switched from an unthreaded build of perl to a threaded build? You might want to try building with -Ud_getgrent_r Looking at the ChangeLog for libnss-pgsql2, I see: * Fixed bug where if you used getpwent, then getspnam, then getpwent you would end up hanging the application (common perl operation) I wonder if there's a similar problem with groups. Tony
To: perlbug-followup [...] perl.org, Сергей Краев <kt315 [...] tagan.ru>
Date: Thu, 2 Nov 2017 13:50:57 +0300
From: Михаил Манерко <asper [...] tagan.ru>
Subject: Re: [perl #132351] perl function getgrent not worked with libnss
Download (untitled) / with headers
text/plain 2.6k
02.11.2017 08:55, Tony Cook via RT пишет:
Show quoted text
Is there any chance you switched from an unthreaded build of perl to a
threaded build?

I downloaded the perl from the git repository.
switched to branch 5.24
compiled with default settings

asper@a ~/INSTALL/perl $ git remote -v
origin    https://perl5.git.perl.org/perl.git (fetch)
origin    https://perl5.git.perl.org/perl.git (push)
asper@a ~/INSTALL/perl $ git status
На ветке maint-5.24
Ваша ветка обновлена в соответствии с «origin/maint-5.24».
нечего коммитить, нет изменений в рабочем каталоге


Show quoted text
You might want to try building with -Ud_getgrent_r

I rebuild perl with
./Configure -de -Dprefix=/opt/perl5 -Ud_getgrent_r
nothing will change functions hang

Show quoted text

Looking at the ChangeLog for libnss-pgsql2, I see:

        * Fixed bug where if you used getpwent, then getspnam, then getpwent
        you would end up hanging the application (common perl operation)

I saw the commit described in Cgangelog libnss_pgsql2, these fixes relate to lib_nss of the function getent_close and backend_close.

partial sequence is called when getgrent
in libnss_pgsql2

...
_nss_pgsql_getgrent_r __libc_lock_lock(lock); _nss_pgsql_setgrent(); __libc_lock_lock(lock); <-- hangs here if getgrent is called from perl version greater than 5.20, but does not hang if getgrent is called from c program like this #include <sys/types.h> #include <grp.h> #include <stdio.h> void main(void) { printf ("name: %s\n",getgrent()->gr_name); }   Show quoted text
I wonder if there's a similar problem with groups.

Tony

A more detailed study showed that a pearl above 5.20 hides using two functions, getgrent and getpwent.

Here is the patch I applied to the libnss_pgsql2 library, this patch fixes both functions , getgrent and getpwent.


diff --git a/src/interface.c b/src/interface.c
index 7c6475c..ced21c6 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -10,12 +10,13 @@
  *
  */
 
+#define _GNU_SOURCE
 #include "nss-pgsql.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <pthread.h>
 
-static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 
 /*
  * passwd functions
@@ -250,7 +251,7 @@ _nss_pgsql_getspent_r(struct spwd *result, char *buffer,
 {
        enum nss_status retval = NSS_STATUS_UNAVAIL;
        int lerrno = 0;
-      
+
        pthread_mutex_lock(&lock);
 
        // Make sure the database is opened in case no one has called setspent()


-- 
Regards,
Michael A. Manerko

Megalink Company, Engineer
318, Chehova street, Taganrog, Russia, 347932
tel work: +7 8634 431431 (ext 159)
tel mobile: +7 999 6939428
sip: 159@tagan.ru
www.tagan.ru
Date: Fri, 3 Nov 2017 10:03:26 +1100
To: Михаил Манерко <asper [...] tagan.ru>
CC: perlbug-followup [...] perl.org, Сергей Краев <kt315 [...] tagan.ru>
From: Tony Cook <tony [...] develop-help.com>
Subject: Re: [perl #132351] perl function getgrent not worked with libnss
Download (untitled) / with headers
text/plain 3.1k
On Thu, Nov 02, 2017 at 01:50:57PM +0300, Михаил Манерко wrote: Show quoted text
> 02.11.2017 08:55, Tony Cook via RT пишет:
> > Is there any chance you switched from an unthreaded build of perl to a > > threaded build?
> > I downloaded the perl from the git repository. > switched to branch 5.24 > compiled with default settings > > asper@a ~/INSTALL/perl $ git remote -v > origin https://perl5.git.perl.org/perl.git (fetch) > origin https://perl5.git.perl.org/perl.git (push) > asper@a ~/INSTALL/perl $ git status > На ветке maint-5.24 > Ваша ветка обновлена в соответствии с «origin/maint-5.24». > нечего коммитить, нет изменений в рабочем каталоге > >
> > You might want to try building with -Ud_getgrent_r
> > I rebuild perl with > ./Configure -de -Dprefix=/opt/perl5 -Ud_getgrent_r > nothing will change functions hang
Ok, thanks. Show quoted text
>
> > > > Looking at the ChangeLog for libnss-pgsql2, I see: > > > > * Fixed bug where if you used getpwent, then getspnam, then getpwent > > you would end up hanging the application (common perl operation)
> > I saw the commit described in Cgangelog libnss_pgsql2, these fixes relate to lib_nss of the function getent_close and > backend_close. > > partial sequence is called when getgrent > in libnss_pgsql2 > > ... > _nss_pgsql_getgrent_r __libc_lock_lock(lock); _nss_pgsql_setgrent(); __libc_lock_lock(lock); <-- hangs here if getgrent > is called from perl version greater than 5.20, but does not hang if getgrent is called from c program like this #include > <sys/types.h> #include <grp.h> #include <stdio.h> void main(void) { printf ("name: %s\n",getgrent()->gr_name); }
> > I wonder if there's a similar problem with groups. > > > > Tony
> > A more detailed study showed that a pearl above 5.20 hides using two functions, getgrent and getpwent. > > Here is the patch I applied to the libnss_pgsql2 library, this patch fixes both functions , getgrent and getpwent.
Yes, but I can only see that lock being held if there's a bug in libnss_pgsql. I had a look, getgrent() (from 1.4.0) is: enum nss_status _nss_pgsql_getgrent_r(struct group *result, char *buffer, size_t buflen, int *errnop) { enum nss_status retval = NSS_STATUS_UNAVAIL; __libc_lock_lock(lock); // Make sure the database is opened in case no one has called setpwent() if(!backend_isopen(CONNECTION_USERGROUP)) { retval = _nss_pgsql_setgrent(); } if(backend_isopen(CONNECTION_USERGROUP)) { retval = backend_getgrent(result, buffer, buflen, errnop); } __libc_lock_unlock(lock); return retval; } Note the call to _nss_pgsql_setgrent() with the lock held. enum nss_status _nss_pgsql_setgrent(void) { enum nss_status retval = NSS_STATUS_UNAVAIL; __libc_lock_lock(lock); if(backend_open(CONNECTION_USERGROUP)) { getent_prepare("allgroups"); retval = NSS_STATUS_SUCCESS; } __libc_lock_unlock(lock); return NSS_STATUS_SUCCESS; } attempts to lock too, and in the call from _nss_pgsql_getgrent_r() it will attempt to lock again. So this appears to be a libnss_pgsql bug, which your change to recursive locks works around. Tony


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org