Skip Menu |

This queue is for tickets about the Date-Manip CPAN distribution.

Report information
The Basics
Id: 105737
Status: resolved
Priority: 0/
Queue: Date-Manip

People
Owner: Nobody in particular
Requestors: Jared.Selengut [...] xls.xerox.com
Cc: tsibley [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: ParseDate never returns for certain inputs
Date: Tue, 7 Jul 2015 20:40:28 +0000
To: "bug-Date-Manip [...] rt.cpan.org" <bug-Date-Manip [...] rt.cpan.org>
From: Jared Selengut <Jared.Selengut [...] xls.xerox.com>
Hello, My apologies if this bug is fixed in a more recent release, but I found an issue today with Date::Manip where it runs indefinitely and uses up all memory for certain inputs to ParseDate. If a numeric string of at least 18 digits is passed, it never returns and starts using unlimited memory at the rate of about 2GB per minute. Please see sample code below. Note that a string of all zeros does not cause a problem, and a string beginning with a minus sign may not either. use strict; use warnings; use Date::Manip; ParseDate('0' x 18); # no problem ParseDate('a' x 18); # no problem ParseDate('1' x 17); # runs for 12 seconds and uses several hundred MB ParseDate('1' x 18); # runs until the system locks up from lack of memory # perl, v5.10.0 built for x86_64-linux-thread-multi # Linux 2.6.27.48-0.6-default x86_64 # Date::Manip 6.24 Jared Selengut Complex Analytics Xerox Litigation Services 80 State St., Suite 300 Albany, NY 12207 p 518.434-6543 x-1961 i 8*328-1961 m 518.382.7607 www.xerox-xls.com<http://www.xerox-xls.com/>
In order to understand what's going on, you have to remember that when parsing a date, it's valid to pass in a delta (i.e. ParseDate('in 2 days') is perfectly valid) and a delta can consist only of a number (i.e. 65000 is equivalent to 'in 65000 seconds'). So, your first two cases do nothing as expected (you're passing in '000000000000000000' which is equivalent to 'in 0 seconds' and 'aaaaaaaaaaaa...' which doesn't parse to anything. In your third case, you pass in '11111111111111111' which, when added to a date, would give a year on the order of 350 million AD (or 350 million BC) which is well beyond what Date::Manip will support. So there is a bug here... Date::Manip shouldn't have hung, but your values should not be used either as they are invalid. I'll add some checks to make it clear that it will fail much faster, and without causing Date::Manip to hang.
This is now fixed. Trying to do a date calculation with too large of a delta will now correctly return an error, and will not hang.