evalEmpire / y2038

Fix time.h on 32 bit machines to work past the year 2038 bug
https://github.com/schwern/y2038/wiki
MIT License
115 stars 24 forks source link

check_max has eaten a CPU for over 10 minutes #2

Closed cowens closed 14 years ago

cowens commented 14 years ago

I am installing Time-y2038-20100225 from CPAN. It has made it to

Building a program to test the range of your system time functions...
cc -Iy2038 -I/Users/cowens/local/lib/perl5/5.10.1/darwin-thread-multi-2level/CORE -c -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include -O3 -o check_max.o check_max.c
cc -fstack-protector -L/opt/local/lib -o check_max check_max.o
  and running it...

But it has been running check_max at 100% CPU usage for 15 minutes now. My gut tells me that it has missed some end condition and is just looping at this point.

OS X 10.2.6, Perl 5.10.1, 64-bit machine

cowens commented 14 years ago

when run by hand, check_max says:

# Trying gmtime(67768036160140800) max... success
# Trying gmtime(-67768036191676800) min... success
# Trying localtime(67768036160140800) max... success
# Trying localtime(-67768036191676800) min... success
# Trying mktime(67768036160140800) max... success
# Trying mktime(-67768036191676800) min... failed
# Trying mktime(-33884018095838400) min... failed
# Trying mktime(-16942009047919200) min... failed
# Trying mktime(-8471004523959600) min... failed
# Trying mktime(-4235502261979800) min... failed
# Trying mktime(-2117751130989900) min... failed
# Trying mktime(-1058875565494950) min... failed
# Trying mktime(-529437782747475) min... failed
# Trying mktime(-264718891373738) min... failed
# Trying mktime(-132359445686870) min... failed
# Trying mktime(-66179722843436) min... failed
# Trying mktime(-33089861421719) min... failed
# Trying mktime(-16544930710861) min... failed
# Trying mktime(-8272465355432) min... failed

And keeps running without saying anything else

cowens commented 14 years ago

It looks like an OS X bug. I can reproduce it with

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char** argv) {
    time_t t = -4136232677718;
    struct tm *date;
    date = localtime(&t);
    return 0;
}
schwern commented 14 years ago

Yep, figure this out last night and reported it to Apple. I'm rewriting check_max to be more robust wrt hangs.

There's already a bug about this in RT so I'm going to close this out. Please track https://rt.cpan.org/Ticket/Display.html?id=40764 instead.