linux - Perl script fails to handle date since 1 January, 2025 - Stack Overflow

admin2025-05-01  2

I have a Perl script on Nagios server checking iLO status of remote servers. It worked fine since 2015; however, since midnight on 1 January 2025, it crashes with the following error:

Day too big - 38351 > 24855
Sec too small - 38351 < 74752
Sec too big - 38351 > 11647
Cannot handle date (0, 0, 0, 1, 0, 2075) at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Convert/Date.pm line 7
Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Convert/Multi.pm line 12.
Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Convert.pm line 7.
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Convert.pm line 7.
Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Compute.pm line 10.
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Compute.pm line 10.
Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units.pm line 3.
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units.pm line 3.
Compilation failed in require at /usr/lib/perl5/5.8.8/Monitoring/Plugin/Functions.pm line 12.
BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/Monitoring/Plugin/Functions.pm line 12.
Compilation failed in require at /usr/lib/perl5/5.8.8/Monitoring/Plugin.pm line 3.
BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/Monitoring/Plugin.pm line 3.
Compilation failed in require at ./check_ilo2_health.pl line 143.
BEGIN failed--compilation aborted at ./check_ilo2_health.pl line 143.
  • RHEL 6.4
  • Perl 5.8.8
  • Nagios 3.3.1
  • Nagios Plugins 1.4.15
  • check_ilo2_health

As I'm not familiar with Perl, it's not clear to me why it should fail on Line 7 in Date.pm

package Math::Calc::Units::Convert::Date;
use base 'Math::Calc::Units::Convert::Base';
use Time::Local qw(timegm);
use strict;
use vars qw(%units %pref %ranges %total_unit_map);

my $min_nice_time = timegm(0, 0, 0, 1, 0, 1975-1900);
my $max_nice_time = timegm(0, 0, 0, 1, 0, 2030-1900);

I understand that components are outdated, but this solution described above worked for 10 years so far.

Was there any specific issue with Perl 5.8.8? Can anyone suggest how to debug this?

I have a Perl script on Nagios server checking iLO status of remote servers. It worked fine since 2015; however, since midnight on 1 January 2025, it crashes with the following error:

Day too big - 38351 > 24855
Sec too small - 38351 < 74752
Sec too big - 38351 > 11647
Cannot handle date (0, 0, 0, 1, 0, 2075) at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Convert/Date.pm line 7
Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Convert/Multi.pm line 12.
Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Convert.pm line 7.
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Convert.pm line 7.
Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Compute.pm line 10.
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Compute.pm line 10.
Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units.pm line 3.
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units.pm line 3.
Compilation failed in require at /usr/lib/perl5/5.8.8/Monitoring/Plugin/Functions.pm line 12.
BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/Monitoring/Plugin/Functions.pm line 12.
Compilation failed in require at /usr/lib/perl5/5.8.8/Monitoring/Plugin.pm line 3.
BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/Monitoring/Plugin.pm line 3.
Compilation failed in require at ./check_ilo2_health.pl line 143.
BEGIN failed--compilation aborted at ./check_ilo2_health.pl line 143.
  • RHEL 6.4
  • Perl 5.8.8
  • Nagios 3.3.1
  • Nagios Plugins 1.4.15
  • check_ilo2_health

As I'm not familiar with Perl, it's not clear to me why it should fail on Line 7 in Date.pm

package Math::Calc::Units::Convert::Date;
use base 'Math::Calc::Units::Convert::Base';
use Time::Local qw(timegm);
use strict;
use vars qw(%units %pref %ranges %total_unit_map);

my $min_nice_time = timegm(0, 0, 0, 1, 0, 1975-1900);
my $max_nice_time = timegm(0, 0, 0, 1, 0, 2030-1900);

I understand that components are outdated, but this solution described above worked for 10 years so far.

Was there any specific issue with Perl 5.8.8? Can anyone suggest how to debug this?

Share Improve this question edited Jan 2 at 17:46 toolic 62.5k21 gold badges79 silver badges128 bronze badges asked Jan 2 at 17:44 piktorpiktor 431 silver badge3 bronze badges 9
  • @toolic Is that bug report from 2018 and not fixed yet? – TLP Commented Jan 2 at 17:53
  • 5 @toolic I think because it uses 1975 as $min_nice_time. Before 2025, the year 75 was treated as 1975, now it's 2075, because of the 50-year window. – Barmar Commented Jan 2 at 18:09
  • Unless that code is from your own program, it should probably not be in the question. It is just confusing. – TLP Commented Jan 2 at 18:10
  • 1 'worked for 10 years so far' isn't bulletproof as it looks at the first sight. – mpapec Commented Jan 2 at 18:20
  • 1 @Barmar: correct, and then it looks like the build is 32bit which means that trying to get the time_t for 2075 will overflow (since max 2038), hence the warnings and finally the croak. See metacpan.org/release/NWCLARK/perl-5.8.8/source/lib/Time/… – Steffen Ullrich Commented Jan 2 at 18:23
 |  Show 4 more comments

1 Answer 1

Reset to default 4

To resolve this issue, I had no choice but to manually apply the patch mentioned above (comment by Toolic):

https://rt.cpan.org/Public/Bug/Display.html?id=124521

Directly in .../perl5/vendor_perl/Math/Calc/Units/Convert/Date.pm

my $min_nice_time = timegm(0, 0, 0, 1, 0, 1975-1900);
my $max_nice_time = timegm(0, 0, 0, 1, 0, 2030-1900);

Change it to:

my $min_nice_time = timegm(0, 0, 0, 1, 0, 1975);
my $max_nice_time = timegm(0, 0, 0, 1, 0, 2030);

And also:

my $timestamp = timegm($s, $m, $h, $d, $M, $y-1900);

->

my $timestamp = timegm($s, $m, $h, $d, $M, $y);
转载请注明原文地址:http://www.anycun.com/QandA/1746104551a91730.html