Grokbase
x

Michael G Schwern (sc...@pobox.com)

Profile | Posts (4049)

User Information

Display Name:Michael G Schwern
Partial Email Address:sc...@pobox.com
Posts:
4049 total
4049 in Perl 5 Porters

5 Most Recent

All Posts
1) Michael G Schwern Re: time.t 64bit fail
| +1 vote
That's year 0 to 30873836848. 0 makes sense, the other one I have no idea. That's not a significant...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
H.Merijn Brand wrote:
>> What's your LOCALTIME_MIN and LOCALTIME_MAX please?
>
> perl-current 103 > grep LOCALTIME_ config.sh
> sLOCALTIME_max='974284125319987199'
> sLOCALTIME_min='-62167219200'

That's year 0 to 30873836848.  0 makes sense, the other one I have no idea.


> # system time.h limits, as JSON
 > {   "gmtime":    { "max": 42489252465868800, "min": -42489252465868800 },
 >     "localtime": { "max": 42489252465868800, "min": -42489252465868800 },

That's not a significant point either, and its troublesome that check_max is
getting different results than Configure.  Its not a hard coded hint, is it?


>> If LOCALTIME_MAX is over 2**48 could you try localtime(2**48) in C please
>> and see if the system library is at fault?
>
> tmp 107 > ./timecheck
>   0:7fffffffffffffff:      1587287-03-17 15:30:07
>   0:8000000000000000:   4293383948-10-16 08:29:52
> ======================
> Sizeof time_t = 8
>   8:7fffffffffffffff:      1587287-03-17 15:30:07
> max:  0x7fffffffffffffff      9223372036854775807
>   8:8000000000000000:   4293383948-10-16 08:29:52
> min: -0x8000000000000000     -9223372036854775808

Well that ain't right.


> gmtime 2**48
> ======================
> Sizeof time_t = 8
>   8:   1000000000000:   4292129631-11-18 10:44:16
>   0x0001000000000000          281474976710656
>
> localtime 2**48
> ======================
> Sizeof time_t = 8
>   8:   1000000000000:   4292129631-11-18 10:44:16
>   0x0001000000000000          281474976710656

That ain't right either.  Should be 1346432780-9-28.

Does Time::y2038 pass tests?

What it looks like is your time functions go wonky in an unpredictable way.
So the binary search that check_max and Configure do will hit a good slice and
get stuck in it.  Looks like this is going to have to be hard coded.  Try this 
little C program that walks through from 2**1-1 to 2**63-1 until the year
stops going up.


--
Whip me, beat me, make my code compatible with VMS! #include <time.h>
#include <stdio.h>
#include <math.h>

int main() {
    time_t now;
    int max = 63;
    long double count;
    struct tm *date;
    int i;
    int last_year = 70;

    for( i = 1; i <= max; i++ ) {
        count = powl(2,i) - 1;
        now = (time_t)count;

        date = gmtime(&now);
        printf("2^%d-1 %s", i, asctime(date));

        if( last_year > date->tm_year )
            break;

        last_year = date->tm_year;
    }

    return 0;
}
2) Michael G Schwern Re: time.t 64bit fail
| +1 vote
Hrm. 2**46 is fine but 2**48 and 2**52 are not. What's your LOCALTIME_MIN and LOCALTIME_MAX please?...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
H.Merijn Brand wrote:
> Fails on 64bit HP-UX since not too long. Note that HP-UX 11.11 and up
> are fine.
>
> ok 51 - year check, gmtime(-70368744177664)
> ok 52 - year check, localtime(-70368744177664)
> ok 53 - year check, gmtime(281474976710656)
> not ok 54 - year check, localtime(281474976710656)
> # Failed at t/op/time.t line 174
> #      got "-2837665"
> # expected "8921556"
> ok 55 - year check, gmtime(4.5035996273705e+15)
> not ok 56 - year check, localtime(4.5035996273705e+15)
> # Failed at t/op/time.t line 174
> #      got "1604708"
> # expected "142715360"
> ok 57 - year check, gmtime(70368744177664)
> ok 58 - year check, localtime(70368744177664)

Hrm.  2**46 is fine but 2**48 and 2**52 are not.

What's your LOCALTIME_MIN and LOCALTIME_MAX please?  If LOCALTIME_MAX is over 
  2**48 could you try localtime(2**48) in C please and see if the system 
library is at fault?

Also please compare what Configure's LOCALTIME_MAX is with what Time::y2038's
SYSTEM_LOCALTIME_MAX is.
http://search.cpan.org/~mschwern/Time-y2038-20100216.1421_04/


--
"I went to college, which is a lot like being in the Army, except when
  stupid people yell at me for stupid things, I can hit them."
-- Jonathan Schwarz
3) Michael G Schwern Re: gmtime/localtime are busted around 2**48
| +1 vote
Excellent, thank you.
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Craig A. Berry wrote:
> On Thu, Feb 4, 2010 at 8:46 PM, Michael G Schwern <schwern@pobox.com> wrote:
>> Michael G Schwern wrote:
>>> Ahh, Time::gmtime tests are now too aggressive and need to be informed
>>> about the raised fence. I'll fix that now.
>> Ok, here's the updated patch. Just lowered the boundaries on the
>> Time::gm/localtime tests. Passes all tests here.
>> http://github.com/schwern/perl/commit/88e23862cae804dd8ffbb32243902c29d2ff89fd.diff
>
> I ran some tests with various configurations and platforms and it
> looked good so I pushed with nothing added except the MANIFEST entry
> for the new test:
>
> http://perl5.git.perl.org/perl.git/commitdiff/fc003d4
>
> We'll see what the smokes say.

Excellent, thank you.


--
package Outer::Space; use Test::More tests => 9;
4) Michael G Schwern Re: gmtime/localtime are busted around 2**48
| +1 vote
Ok, here's the updated patch. Just lowered the boundaries on the Time::gm/localtime tests. Passes...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Michael G Schwern wrote:
> Ahh, Time::gmtime tests are now too aggressive and need to be informed
> about the raised fence.  I'll fix that now.

Ok, here's the updated patch.  Just lowered the boundaries on the 
Time::gm/localtime tests.  Passes all tests here.
http://github.com/schwern/perl/commit/88e23862cae804dd8ffbb32243902c29d2ff89fd.diff


PS  I discovered that if you stick a .diff on the end of a github commit URL 
it'll give you a raw diff.


--
39. Not allowed to ask for the day off due to religious purposes, on the
     basis that the world is going to end, more than once.
     -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
http://skippyslist.com/list/
5) Michael G Schwern Re: gmtime/localtime are busted around 2**48
| +1 vote
I messed up the warning suppression in the test. I put out so many versions of the patch I kind of...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Craig A. Berry wrote:
> Sorry to be AWOL the last few days -- $work and such. I've applied
> the "0002-Don-t-try-to-calculate..." patch locally and started to test
> it. On OS X Leopard on PPC G5 configured with -Dusedevel -des, I see
> the following failures:
>
> t/op/time......................................................ok
> t/op/time_loop.................................................gmtime(590295810358705651712)
> failed at op/time_loop.t line 15.
> localtime(590295810358705651712) failed at op/time_loop.t line 16.
> ok
>
> [um, that's not exactly a failure, but a failure to fail, or something]

I messed up the warning suppression in the test.  I put out so many versions 
of the patch I kind of lost track.  The versions on 
http://github.com/schwern/perl y2038-min branch and in perlbug are correct.

The proper line is:

     local $SIG{__WARN__} = sub {};

Because you can't predict which message will come out (failed, too small or
too big).  I suppose it could be tightened up by checking for /\Qtime(/ in the 
warning but I'm not worried at this point.


> . . .
> lib/Time/gmtime................................................Can't
> call method "sec" on an undefined value at ../lib/Time/gmtime.t line
> 25.
> # Looks like you planned 109 tests but ran 1.
> FAILED--expected 109 tests, saw 1
> lib/Time/localtime.............................................Can't
> call method "sec" on an undefined value at ../lib/Time/localtime.t
> line 25.
> # Looks like you planned 109 tests but ran 1.
> FAILED--expected 109 tests, saw 1
> lib/Unicode/UCD................................................ok
>
> so we're not quite there yet. I'm going to see what I can see but am
> not in a position to make promises about when.

Ahh, Time::gmtime tests are now too aggressive and need to be informed about
the raised fence.  I'll fix that now.


--
If you want the truth to stand clear before you, never be for or against.
The struggle between "for" and "against" is the mind's worst disease.
-- Sent-ts'an

spacer
Profile | Posts (4049)
Home > People > Michael G Schwern