Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.94k stars 554 forks source link

POSIX::setlocale returns bizarre value on failure #12590

Closed p5pRT closed 11 years ago

p5pRT commented 11 years ago

Migrated from rt.perl.org#115808 (status was 'resolved')

Searchable as RT115808$

p5pRT commented 11 years ago

From @mauke

Created by @mauke

POSIX​::setlocale returns a bizarre value on failure.

$ perl -wle 'use POSIX; print scalar(()= setlocale LC_ALL\, "mtfnpy")' 1

OK\, so it's not an empty list.

$ perl -wle 'use POSIX; print setlocale LC_ALL\, "mtfnpy"'

OK\, so it's some kind of empty string (no "uninitialized" warning from -w)

$ perl -wle 'use POSIX; print "" eq setlocale POSIX​::LC_ALL\, "mtfnpy"' 1

Yep\, definitely an empty string.

$ perl -wle 'use POSIX; print defined(setlocale LC_ALL\, "mtfnpy") ? "yes" : "no"' no

Wait\, so it's an empty string that's not undef AND not defined()?

$ perl -wle 'use POSIX; print length setlocale POSIX​::LC_ALL\, "mtfnpy"' Use of uninitialized value in print at -e line 1.

... and length doesn't even bother returning a number for it.

Perl Info ``` Flags: category=library severity=low module=POSIX Site configuration information for perl 5.16.2: Configured by mauke at Thu Nov 1 15:23:47 CET 2012. Summary of my perl5 (revision 5 version 16 subversion 2) configuration: Platform: osname=linux, osvers=2.6.32-5-686, archname=i686-linux uname='linux debian-vb 2.6.32-5-686 #1 smp sun sep 23 09:49:36 utc 2012 i686 gnulinux ' config_args='-Dprefix=/home/mauke/usr -Doptimize=-O2 -flto -Dldflags=-fstack-protector -L/usr/local/lib -O2 -flto -Dlddlflags=-shared -O2 -flto -L/usr/local/lib -fstack-protector -Dcf_email=l.mai@web.de -Dperladmin=none -de' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2 -flto', cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.7.1', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags ='-fstack-protector -L/usr/local/lib -O2 -flto' libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib /usr/lib/i486-linux-gnu /usr/lib64 libs=-lnsl -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.11.3.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.11.3' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -flto -L/usr/local/lib -fstack-protector' Locally applied patches: SAVEARGV0 - disable magic open in @INC for perl 5.16.2: /home/mauke/usr/lib/perl5/site_perl/5.16.2/i686-linux /home/mauke/usr/lib/perl5/site_perl/5.16.2 /home/mauke/usr/lib/perl5/5.16.2/i686-linux /home/mauke/usr/lib/perl5/5.16.2 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux /home/mauke/usr/lib/perl5/site_perl/5.16.1 /home/mauke/usr/lib/perl5/site_perl . Environment for perl 5.16.2: HOME=/home/mauke LANG=en_US.utf8 LANGUAGE (unset) LC_COLLATE=POSIX LD_LIBRARY_PATH=/home/mauke/usr/lib LOGDIR (unset) PATH=/home/mauke/perl5/perlbrew/bin:/home/mauke/.cabal/bin:/home/mauke/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games PERLBREW_BASHRC_VERSION=0.55 PERLBREW_HOME=/home/mauke/.perlbrew PERLBREW_ROOT=/home/mauke/perl5/perlbrew PERL_BADLANG (unset) PERL_UNICODE=SAL SHELL=/bin/bash ```
p5pRT commented 11 years ago

From @cpansprout

On Sun Nov 18 13​:59​:40 2012\, mauke- wrote​:

This is a bug report for perl from l.mai@​web.de\, generated with the help of perlbug 1.39 running under perl 5.16.2.

----------------------------------------------------------------- [Please describe your issue here]

POSIX​::setlocale returns a bizarre value on failure.

$ perl -wle 'use POSIX; print scalar(()= setlocale LC_ALL\, "mtfnpy")' 1

OK\, so it's not an empty list.

$ perl -wle 'use POSIX; print setlocale LC_ALL\, "mtfnpy"'

OK\, so it's some kind of empty string (no "uninitialized" warning from -w)

$ perl -wle 'use POSIX; print "" eq setlocale POSIX​::LC_ALL\, "mtfnpy"' 1

Yep\, definitely an empty string.

$ perl -wle 'use POSIX; print defined(setlocale LC_ALL\, "mtfnpy") ? "yes" : "no"' no

Wait\, so it's an empty string that's not undef AND not defined()?

$ perl -wle 'use POSIX; print length setlocale POSIX​::LC_ALL\, "mtfnpy"' Use of uninitialized value in print at -e line 1.

... and length doesn't even bother returning a number for it.

Anything marked PADTMP is exempt from uninit warnings. I have no idea why.

--

Father Chrysostomos

p5pRT commented 11 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 11 years ago

From @ap

* l.mai@​web.de \perlbug\-followup@​perl\.org [2012-11-18 23​:05]​:

$ perl -wle 'use POSIX; print length setlocale POSIX​::LC_ALL\, "mtfnpy"' Use of uninitialized value in print at -e line 1.

... and length doesn't even bother returning a number for it.

That’s what `length undef` does.

p5pRT commented 11 years ago

From @khwilliamson

Fixed by commit fbd840dfc9b563b320e11bc4465883053a0487f5 -- Karl Williamson

p5pRT commented 11 years ago

From [Unknown Contact. See original ticket]

Fixed by commit fbd840dfc9b563b320e11bc4465883053a0487f5 -- Karl Williamson

p5pRT commented 11 years ago

@khwilliamson - Status changed from 'open' to 'resolved'