develooper Front page | perl.perl5.porters | Postings from February 2003

[perl #20939] getgrent fails on Solaris 8 with large groups, perl5.8.0 with threads

Thread Next
From:
perlbug-followup
Date:
February 13, 2003 13:49
Subject:
[perl #20939] getgrent fails on Solaris 8 with large groups, perl5.8.0 with threads
Message ID:
rt-20939-51182.17.5553765425407@bugs6.perl.org
# New Ticket Created by  ramey@ti.com 
# Please include the string:  [perl #20939]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=20939 >



This is a bug report for perl from ramey@ti.com,
generated with the help of perlbug 1.34 running under perl v5.8.0.


-----------------------------------------------------------------
This script should print all the groups in our NIS+ table:
=================================================================
 while(@F = getgrent()) {
   $cnt++;
   print "GOT: $F[0] ($cnt)\n";
 }
=================================================================

It works on older versions of perl but not on 5.8.0 built with threads
support.  It prints some of the groups but stops before it should.

I think I've found the problem and a fix for it.  Perl is calling
getgrent_r() instead of getgrent() since it's using threads.  It
appears to be passing in a buffer that is too small to hold some of
the large groups we have, and when getgrent_r() encounters a group
that's too big for the buffer, it returns 0.

I believe that this change to reentr.pl will fix the problem:

------------------------------------------------------------------------------
*** reentr.pl.ORIG      Thu Feb 13 11:39:19 2003
--- reentr.pl   Thu Feb 13 15:14:54 2003
***************
*** 506,514 ****
        PL_reentrant_buffer->_${genfunc}_fptr = NULL;
  #   endif
  EOF
!               my $sc = $genfunc eq 'getgrent' ?
                    '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX';
!               my $sz = $genfunc eq 'getgrent' ?
                      '_grent_size' : '_pwent_size';
                push @size, <<EOF;
  #   if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
--- 506,514 ----
        PL_reentrant_buffer->_${genfunc}_fptr = NULL;
  #   endif
  EOF
!               my $sc = $genfunc eq 'grent' ?
                    '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX';
!               my $sz = $genfunc eq 'grent' ?
                      '_grent_size' : '_pwent_size';
                push @size, <<EOF;
  #   if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
------------------------------------------------------------------------------

$genfunc was canonicalized earlier such that the leading `get' was
removed.  So, it needs to be compared against `grent' instead of
`getgrent'.

I tested this fix with my sample script (above) and it seems to fix
the problem.

Joe Ramey
ramey@ti.com

-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.8.0:

Configured by damon at Sun Nov  3 18:27:53 CST 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.7, archname=sun4-solaris-thread-multi
    uname='sunos monroe.dal.mslp.ti.com 5.7 generic_106541-20 sun4u sparc sunw,ultra-60 '
    config_args='-Duseshrplib -Dusethreads -Dcc=gcc -Dprefix=/apps/perl/5.8.0'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -fno-strict-aliasing -I/apps/perl/5.8.0/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-D_REENTRANT -fno-strict-aliasing -I/apps/perl/5.8.0/include'
    ccversion='', gccversion='3.2', gccosandvers='solaris2.7'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags ='-L/apps/perl/5.8.0/lib -R/apps/perl/5.8.0/lib '
    libpth=/apps/perl/5.8.0/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldb -ldl -lm -lrt -lpthread -lc
    perllibs=-lsocket -lnsl -ldl -lm -lrt -lpthread -lc
    libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -R /apps/perl/5.8.0/lib/perl5/5.8.0/sun4-solaris-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-G -L/apps/perl/5.8.0/lib -R/apps/perl/5.8.0/lib'

Locally applied patches:
    

---
@INC for perl v5.8.0:
    /apps/perl/5.8.0/lib/perl5/5.8.0/sun4-solaris-thread-multi
    /apps/perl/5.8.0/lib/perl5/5.8.0
    /apps/perl/5.8.0/lib/perl5/site_perl/5.8.0/sun4-solaris-thread-multi
    /apps/perl/5.8.0/lib/perl5/site_perl/5.8.0
    /apps/perl/5.8.0/lib/perl5/site_perl
    .

---
Environment for perl v5.8.0:
    HOME=/home/ramey
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/sbin:/home/ramey/bin:/bin:/usr/local/bin:/opt/SUNWspro/bin:/usr/ccs/bin:/home/sysadmin/bin:/usr/X11R6/bin:/home/ramey/bin:/usr/ucb:/usr/local/etc:/bin:/usr/bin:/usr/games:/etc:/usr/openwin/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About