Edit report at http://bugs.php.net/bug.php?id=52808&edit=1
ID: 52808 Updated by: s...@php.net Reported by: j...@php.net Summary: Segfault when specifying interval as two dates -Status: Assigned +Status: Closed Type: Bug Package: Date/time related Operating System: Debian stable PHP Version: 5.3, trunk Assigned To: derick Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2011-01-30 09:54:55] s...@php.net Automatic comment from SVN on behalf of stas Revision: http://svn.php.net/viewvc/?view=revision&revision=307846 Log: Fix bug #52808 (Segfault when specifying interval as two dates) ------------------------------------------------------------------------ [2010-09-11 00:22:09] srina...@php.net looks like my comment was lost in the previous post while uploading my patch. i was wondering, if dateinterval constructor accepts a general format of date string. looking at the code it does not seem to be as well. manual suggests that you need to provide the input date in format ISO8601 format. for example year 10th may, 2008 would be given as $a = new DateInterval("P2008Y5M11DT15H30M00S"); I haven't used this API much.So, I could be wrong. ------------------------------------------------------------------------ [2010-09-09 23:45:25] j...@php.net Description: ------------ Creating an interval with a "negative duration" (i.e., "start" date precedes "end" date) creates what appears to be a valid DateInterval object, but any attempt to work with the object results in a segfault. Test script: --------------- <?php $a = new DateInterval("2008-05-11T15:30:00Z/2007-03-01T13:00:00Z"); var_dump($a); ?> Expected result: ---------------- At a minimum, "Not crashing". Ideally, a DateInterval object with a negative duration, but I don't know of ISO-8601 allows those. Actual result: -------------- (gdb) r -r '$a = new DateInterval("2008-05-11T15:30:00Z/2007-03-01T13:00:00Z"); var_dump($a);' Program received signal SIGSEGV, Segmentation fault. 0x0000000000420faf in date_object_get_properties_interval (object=<value optimized out>) at /home/joey/src/php/trunk/ext/date/php_date.c:2242 2242 PHP_DATE_INTERVAL_ADD_PROPERTY("y", y); "bt full" output available at http://codepad.org/on7ZS6Qd ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52808&edit=1