|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52808 Segfault when specifying interval as two dates
Submitted: 2010-09-09 23:45 UTC Modified: 2011-01-30 09:55 UTC
From: Assigned: derick
Status: Closed Package: Date/time related
PHP Version: 5.3, trunk OS: Debian stable
Private report: No CVE-ID:
 [2010-09-09 23:45 UTC]
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


bug52808.patch (last revision 2010-09-10 22:18 UTC) by sriram dot natarajan at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-09 23:46 UTC]
-Assigned To: +Assigned To: derick
 [2010-09-11 00:22 UTC]
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-12-05 17:01 UTC]
-PHP Version: trunk-SVN-2010-09-09 (SVN) +PHP Version: 5.3, trunk
 [2011-01-30 09:42 UTC]
-Summary: Negative intervals segfault +Summary: Segfault when specifying interval as two dates
 [2011-01-30 09:54 UTC]
Automatic comment from SVN on behalf of stas
Log: Fix bug #52808 (Segfault when specifying interval as two dates)
 [2011-01-30 09:55 UTC]
-Status: Assigned +Status: Closed
 [2011-01-30 09:55 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 16:01:30 2015 UTC