Perl / perl5

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

Time::Piece strptime broken on netbsd and openbsd #13449

Closed p5pRT closed 10 years ago

p5pRT commented 10 years ago

Migrated from rt.perl.org#120655 (status was 'rejected')

Searchable as RT120655$

p5pRT commented 10 years ago

From perl@plan9.de

Created by perl@plan9.de

The Time​::Piece manpage documents this​:

  Time​::Piece has a built-in strptime() function (from FreeBSD)\, allowing   you incredibly flexible date parsing routines. For example​:

Apart from FreeBSDs strptime not at all being flexible (I have yet to find a date format used on the internets that it can parse)\, it's also broken on netbsd and openbsd (found out via cpan-testers).

It seems Time​::Piece doesn't work as documented at all - investigating the source indicates that it uses the system-provided strptime\, so there is no way to know which fornmat specifiers are supported (and working) and which aren't.

For example\, on openbsd 5.0\, strptime documents %z\, but it has no effect. I didn't investigate the netbsd failures\, but they likely share that bug.

So\, either the documentation is wrong\, or the code. Since fixing the documentation has the side effect of making strptime useless for portable applications\, it would be best if the code were fixed to match the documentation.

Perl Info ``` Flags: category=library severity=low module=Time::Piece Site configuration information for perl 5.18.1: Configured by Marc Lehmann at Mon Oct 21 09:27:08 CEST 2013. Summary of my perl5 (revision 5 version 18 subversion 1) configuration: Platform: osname=linux, osvers=3.10-3-amd64, archname=x86_64-linux uname='linux cerebro 3.10-3-amd64 #1 smp debian 3.10.11-1 (2013-09-10) x86_64 gnulinux ' config_args='-Duselargefiles -Duse64bitint -Dusemymalloc=n -Dstatic_ext=Fcntl -Dcc=ccache gcc -Dccflags=-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -USITEARCH_EXP -USITELIB_EXP -UARCHLIB_EXP -D_GNU_SOURCE -I/opt/include -ggdb -gdwarf-2 -g3 -Doptimize=-O6 -fno-asynchronous-unwind-tables -fno-strict-aliasing -Dcccdlflags=-fPIC -Dldflags=-L/opt/perl/lib -L/opt/lib -Dlibs=-ldl -lm -lcrypt -Dprefix=/opt/perl -Dprivlib=/opt/perl/lib/perl5 -Darchlib=/opt/perl/lib/perl5 -Uusevendorprefix -Dsiteprefix=/opt/perl -Dsitelib=/opt/perl/lib/perl5 -Dsitearch=/opt/perl/lib/perl5 -Dsitebin=/opt/perl/bin -Dman1dir=/opt/perl/man/man1 -Dman3dir=/opt/perl/man/man3 -Dsiteman1dir=/opt/perl/man/man1 -Dsiteman3dir=/opt/perl/man/man3 -Dman1ext=1 -Dman3ext=3 -Dpager=/usr/bin/less -Uafs -Uusesfio -Uusenm -Uuseshrplib -Ud_dosuid -Dusethreads=undef -Duse5005threads=undef -Duseithreads=undef -Dusemultiplicity=undef -Demail=perl-binary@plan9.de -Dcf_email=perl-binary@plan9.de -Dcf_by=Marc Lehmann -Dlocincpth=/opt/perl/include /opt/include -Dmyhostname=localhost -Dmultiarch=undef -Dbin=/opt/perl/bin -Dxxxusedevel -DxxxDEBUGGING -Dxxxuse_debugging_perl -Dxxxuse_debugmalloc -dEs' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='ccache gcc', ccflags ='-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -USITEARCH_EXP -USITELIB_EXP -UARCHLIB_EXP -D_GNU_SOURCE -I/opt/include -ggdb -gdwarf-2 -g3 -fno-strict-aliasing -pipe -I/opt/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O6 -fno-asynchronous-unwind-tables -fno-strict-aliasing', cppflags='-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -USITEARCH_EXP -USITELIB_EXP -UARCHLIB_EXP -D_GNU_SOURCE -I/opt/include -ggdb -gdwarf-2 -g3 -fno-strict-aliasing -pipe -I/opt/include' ccversion='', gccversion='4.7.2', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='ccache gcc', ldflags ='-L/opt/perl/lib -L/opt/lib -L/usr/local/lib' libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib libs=-ldl -lm -lcrypt perllibs=-ldl -lm -lcrypt libc=, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.17' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O6 -fno-asynchronous-unwind-tables -fno-strict-aliasing -L/opt/perl/lib -L/opt/lib -L/usr/local/lib' Locally applied patches: @INC for perl 5.18.1: /root/src/sex /root/pserv/lib/perl5 /opt/perl/lib/perl5 /opt/perl/lib/perl5 . Environment for perl 5.18.1: HOME=/root LANG (unset) LANGUAGE (unset) LC_CTYPE=en_US.UTF-8 LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/root/s2:/root/s:/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11/bin:/usr/games:/usr/local/bin:/usr/local/sbin:/root/pserv:. PERL5LIB=/root/src/sex:/root/pserv/lib/perl5 PERL5_CPANPLUS_CONFIG=/root/.cpanplus/config PERLDB_OPTS=ornaments=0 PERL_ANYEVENT_DBI_TESTS=1 PERL_ANYEVENT_LOOP_TESTS=1 PERL_ANYEVENT_NET_TESTS=1 PERL_BADLANG (unset) PERL_UNICODE=E SHELL=/bin/bash ```
p5pRT commented 10 years ago

From @nwc10

On Sun\, Dec 01\, 2013 at 10​:30​:04PM -0800\, perl@​plan9.de wrote​:

The Time​::Piece manpage documents this​:

Time​::Piece has a built-in strptime() function (from FreeBSD)\, allowing you incredibly flexible date parsing routines. For example​:

Apart from FreeBSDs strptime not at all being flexible (I have yet to find a date format used on the internets that it can parse)\, it's also broken on netbsd and openbsd (found out via cpan-testers).

It seems Time​::Piece doesn't work as documented at all - investigating the source indicates that it uses the system-provided strptime\, so there is no way to know which fornmat specifiers are supported (and working) and which aren't.

For example\, on openbsd 5.0\, strptime documents %z\, but it has no effect. I didn't investigate the netbsd failures\, but they likely share that bug.

So\, either the documentation is wrong\, or the code. Since fixing the documentation has the side effect of making strptime useless for portable applications\, it would be best if the code were fixed to match the documentation.

The intent certainly is that it should behave as per the documentation.

Current version is 1.23. The changelog says this​:

  1.17   - Force all to use internal strptime then everyone gets %z even OSX   users.   - Finally figured out the timezone test failures on Win32 and fixed   them.

which seems to be describing pretty much the problem that you're reporting here.

That was pulled into blead with this commit​:

commit 90d55c29481047f2784ec1daadd553c5710e090a Author​: Chris 'BinGOs' Williams \chris@​bingosnet\.co\.uk Date​: Sat Jun 26 15​:04​:03 2010 +0100

  Update Time-Piece to CPAN version 1.20

[etc]

so anything v5.14.0 and later is shipping a version that *should* be doing exactly what the docs say (and what you need from it).

The XS source code no longer references the C library strptime\, and nm confirms this on blead​:

$ nm lib/auto/Time/Piece/Piece.so | grep strp 0000000000004b5f t XS_Time__Piece__strptime 00000000000020b5 t _strptime 0000000000003914 T our_strptime

compare with the version shipped with a clean v5.12.4 build​:

$ nm lib/auto/Time/Piece/Piece.so | grep strp 0000000000003c6a T XS_Time__Piece__strptime   U strptime@​@​GLIBC_2.2.5

Were the versions that you report had broken %z handling using v5.12.4 (or earlier)\, with an older version of Time​::Piece? (These are machines on CPANTesters\, or machines you can access directly?)

Otherwise\, I can't figure out why you'd be seeing what you report.

Nicholas Clark

p5pRT commented 10 years ago

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

p5pRT commented 10 years ago

From schmorp@schmorp.de

On Tue\, Dec 03\, 2013 at 02​:07​:37AM -0800\, Nicholas Clark via RT \perlbug\-followup@​perl\.org wrote​:

so anything v5.14.0 and later is shipping a version that *should* be doing exactly what the docs say (and what you need from it).

Hmm\, it seems all is in order then.

Were the versions that you report had broken %z handling using v5.12.4 (or earlier)\, with an older version of Time​::Piece? (These are machines on CPANTesters\, or machines you can access directly?)

The cpantester machines are older\, and while I was under the impression that my boxes had a newer perl\, they were at 12.4 or earlier\, so I guess my report is bogus and it's all fixed.

I'll upgrade Time​::Piece and will report back in the unlikely case that it isn't fixed.

Sorry for the noise.

--   The choice of a Deliantra\, the free code+content MORPG   -----==- _GNU_ http​://www.deliantra.net   ----==-- _ generation   ---==---(_)__ __ ____ __ Marc Lehmann   --==---/ / _ \/ // /\ \/ / schmorp@​schmorp.de   -=====/_/_//_/\_\,_/ /_/\_\

p5pRT commented 10 years ago

From @jkeenan

On Wed Dec 04 11​:08​:44 2013\, schmorp@​schmorp.de wrote​:

On Tue\, Dec 03\, 2013 at 02​:07​:37AM -0800\, Nicholas Clark via RT \perlbug\-followup@​perl\.org wrote​:

so anything v5.14.0 and later is shipping a version that *should* be doing exactly what the docs say (and what you need from it).

Hmm\, it seems all is in order then.

Were the versions that you report had broken %z handling using v5.12.4 (or earlier)\, with an older version of Time​::Piece? (These are machines on CPANTesters\, or machines you can access directly?)

The cpantester machines are older\, and while I was under the impression that my boxes had a newer perl\, they were at 12.4 or earlier\, so I guess my report is bogus and it's all fixed.

I'll upgrade Time​::Piece and will report back in the unlikely case that it isn't fixed.

Sorry for the noise.

It appears this issue is resolved. I'll take the ticket for the purpose of closing it within 7 days. If anyone thinks the ticket should stay open\, please let us know.

Thank you very much. Jim Keenan

p5pRT commented 10 years ago

From @jkeenan

On Tue Dec 10 16​:13​:37 2013\, jkeenan wrote​:

It appears this issue is resolved. I'll take the ticket for the purpose of closing it within 7 days. If anyone thinks the ticket should stay open\, please let us know.

Thank you very much. Jim Keenan

Closing as per schedule.

p5pRT commented 10 years ago

@jkeenan - Status changed from 'open' to 'rejected'