Bug 1057047 - perl Time::Local does not work with dates after 2038 or below 1902
Summary: perl Time::Local does not work with dates after 2038 or below 1902
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: perl
Version: 5.11
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: perl-maint-list
QA Contact: Lukáš Zachar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-23 12:07 UTC by Victor Efimov
Modified: 2014-10-22 08:08 UTC (History)
2 users (show)

Fixed In Version: perl-5.8.8-42.el5
Doc Type: Bug Fix
Doc Text:
Cause: Using timegm() Perl function to convert calendar time beyond year 2038 into number of seconds elapsed from the UNIX epoch beginning on 64-bit platform. Consequence: timegm() function refuses to convert such date and an error message gets printed. Fix: An upstream fix has been applied to detect 64-bit perl correctly. Result: It's possible to convert dates beyond year 2038 with Perl's timegm() function on 64-bit platforms. 32-bit platforms will still refuse such requests as system time_t type is not large enough on 32-bit platforms.
Clone Of:
Environment:
Last Closed: 2014-09-16 00:32:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Fix ported from Time-Local-1.19 (3.60 KB, patch)
2014-01-24 09:49 UTC, Petr Pisar
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
CPAN 31497 0 None None None Never
Red Hat Bugzilla 1149375 0 urgent CLOSED Time::Local patch for year 2038 on 64 bit breaks timelocal 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 1155140 0 unspecified CLOSED DST not taken into account on dates after 2038 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHBA-2014:1198 0 normal SHIPPED_LIVE perl bug fix update 2014-09-16 04:17:13 UTC

Internal Links: 1149375 1155140

Description Victor Efimov 2014-01-23 12:07:19 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:
run
perl -MTime::Local -e 'timegm(0, 0, 0, 01, 01, 2038)'


Steps to Reproduce:
1. run perl -MTime::Local -e 'timegm(0, 0, 0, 01, 01, 2038)'

Actual results:

Day too big - 24868 > 24855
Sec too small - 24868 < 74752
Sec too big - 24868 > 11647
Cannot handle date (0, 0, 0, 1, 1, 2038) at -e line 1.


Expected results:

no warnings/errors printed

Additional info:

Reproducible on 64 bit machines.

Also does not work for dates < ~ 1902

Bug in perl core module Time::Local, I think it's fixed in 1.19 I'd suggest to backport a fix, it's something related to wrong type for Integers.

Comment 1 Petr Pisar 2014-01-23 12:24:14 UTC
Full support for times after year 2038 has been introduced in perl 5.12 while distribution provides perl 5.8.8.

Comment 2 Victor Efimov 2014-01-23 12:36:16 UTC
Yes, there is notice in 5.12 delta: http://search.cpan.org/~jesse/perl-5.12.0/pod/perl5120delta.pod#Y2038_compliance about Y2038

However I am not sure what that means, what exactly was not working prior to that fix? (maybe it was time() function which does not afect users until Y2038).

The problem I described is fixed in 5.8.9 (i.e. Time::Local 1.19). 5.8.9 is latest stable release of 5.8.x branch.
Also this problem can afferct users right now, before Y2038.

Comment 3 Victor Efimov 2014-01-23 16:37:41 UTC
UPD:

It seems on 64bit machines problem fixed in 5.8.9 (Time::Local 1.19).

On 32bit machines problem indeed fixed with 5.12.0 (I tested original perl tarballs) (even if compiled with 64bit ints support)

So, you were right, and I am not sure now if it's worth fixing.

Comment 4 Victor Efimov 2014-01-23 20:43:03 UTC
also, 32bit linux, in general don't seem to support Y2038 in file system date/time functions and maybe other API call. so support for 32bit perls makes less sense anyway.

Comment 5 Petr Pisar 2014-01-24 09:48:26 UTC
Definitely. 5.12.0 solved the problem by adding private localtime implementations and the change is too invasive and it changes ABI, so I cannot back-port the perl changes to support 32-bit platforms.

However Time::Local fix to add support on 64-bit platforms is easy and without any significant problems (only it does not croak on too big year, but that's problem even with latest perl).

The fix seems correct as the time_t size correspond with ivsize used in the fix:

platform    time_t  intsize ivsize
------------------------------------------
ppc         4       4       4
s390        4       4       4
x86_64      8       4       8
ppc64       8       4       8
s390x       8       4       8
i386        4       4       4
ia64        8       4       8

I also verified the patch does not break things on i386 and fixes the issue in x86_64.

Comment 6 Petr Pisar 2014-01-24 09:49:34 UTC
Created attachment 854867 [details]
Fix ported from Time-Local-1.19

Comment 7 RHEL Program Management 2014-01-24 10:19:22 UTC
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux release.  Product Management has
requested further review of this request by Red Hat Engineering, for
potential inclusion in a Red Hat Enterprise Linux release for currently
deployed products.  This request is not yet committed for inclusion in
a release.

Comment 9 Petr Pisar 2014-02-11 15:31:06 UTC
How to test:

(1) Run:
 $ perl -MTime::Local -e 'print timegm(0, 0, 0, 01, 01, 2038), qq{\n}'
Before: It will die with various errors as mentioned in the comment #1.
After:  It will print number 2148595200. Make sure you check for this value (number of seconds since the epoch beginning).

Please note that it will still fail on 32-bit systems. This is expected.

Comment 14 errata-xmlrpc 2014-09-16 00:32:14 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1198.html

Comment 15 Petr Pisar 2014-10-08 11:25:33 UTC
This patch caused a regression in using Time::Locale::timelocale(). See bug #1149375.

Comment 16 Lukáš Zachar 2014-10-22 07:39:21 UTC
DST on dates after 2038 is not processed correctly, likely to be a glibc bug 1155140.

Comment 17 Petr Pisar 2014-10-22 08:08:25 UTC
Yes. That's because perl-5.8.8 relies on glibc.


Note You need to log in before you can comment on or make changes to this bug.