php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45562 Creating instance of DatePeriod crashes
Submitted: 2008-07-19 08:16 UTC Modified: 2008-07-20 20:59 UTC
From: mathieuk at gmail dot com Assigned: derick (profile)
Status: Closed Package: Reproducible crash
PHP Version: 5.3CVS-2008-07-19 (CVS) OS: MacOSX 10.5.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mathieuk at gmail dot com
New email:
PHP Version: OS:

 

 [2008-07-19 08:16 UTC] mathieuk at gmail dot com
Description:
------------
The new DatePeriod class seems to crash PHP in different ways. 







Reproduce code:
---------------
Crash #1: invalid argument: arg #1 should be DateTime

<?php

$dp = new DatePeriod('2D');

?>

Crash #2: valid argument (i think):
<?php

$begin = new DateTime();
$interval = DateInterval::createFromDateString("1 day");

$dp = new DatePeriod($begin, $interval, 10);

?>




Expected result:
----------------
$dp to be an instance of DatePeriod. Possibly an exception for giving it 
an unknown argument ( not sure what the syntax of the argument should be 
).






Actual result:
--------------
Crashes in both cases:

Crash #1: invalid argument:
-----------------------------------------
(gdb) run DatePeriod.php
Starting program: /Users/mathieu/programs/php/bin/php DatePeriod.php
Reading symbols for shared libraries ++++++.. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x000000a0
0x00050d45 in timelib_update_ts ()
(gdb) bt
#0  0x00050d45 in timelib_update_ts ()
#1  0x000317f9 in zim_DatePeriod___construct ()
#2  0x00295bec in zend_do_fcall_common_helper_SPEC ()
#3  0x00294885 in execute ()
#4  0x00272276 in zend_execute_scripts ()
#5  0x00219114 in php_execute_script ()
#6  0x0031d10e in main ()
------------------------------------------

Crash #2: valid argument:
------------------------------------------
(gdb) run DatePeriod.php 
Starting program: /Users/mathieu/programs/php/bin/php DatePeriod.php
Reading symbols for shared libraries ++++++.. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x00052649 in timelib_strtointerval ()
(gdb) bt
#0  0x00052649 in timelib_strtointerval ()
#1  0x0003177e in zim_DatePeriod___construct ()
#2  0x00295bec in zend_do_fcall_common_helper_SPEC ()
#3  0x00294885 in execute ()
#4  0x00272276 in zend_execute_scripts ()
#5  0x00219114 in php_execute_script ()
#6  0x0031d10e in main ()
--------------------------------------------------

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-20 20:59 UTC] derick@php.net
This bug has been fixed in CVS.

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.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 15:01:35 2025 UTC