php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74639 Cloning DatePeriod leads to segfault
Submitted: 2017-05-23 14:02 UTC Modified: 2017-05-26 12:47 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: j dot baron at gingco dot net Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 7.1.5 OS: Linux and Windows
Private report: No CVE-ID:
 [2017-05-23 14:02 UTC] j dot baron at gingco dot net
Description:
------------
Tested PHP version: 7.1.5 (Windows + Linux), 7.1.0RC6 (Linux),

Configure line (No non-standard extensions):

'./configure'  '--prefix=/home/jost/php/installs/7.1.5' '--enable-static' '--enable-calendar' '--enable-exif' '--enable-ftp' '--with-gettext' '--enable-mbstring' '--with-mcrypt' '--with-mysqli' '--enable-pcntl' '--with-pdo-pgsql=/var/lib/postgresql/9.3/' '--with-pgsql=/var/lib/postgresql/9.3/' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-sockets' '--enable-zip' '--with-zlib-dir' '--with-pcre-dir' '--with-openssl' '--with-gd' '--with-readline' '--with-bz2' '--with-curl' '--enable-bcmath' '--enable-maintainer-zts' '--enable-intl' '--enable-debug' '--disable-maintainer-zts'

php.ini:

Loaded Configuration File => (none)
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)



Test script:
---------------
https://pastebin.com/kP4tRJyt

Expected result:
----------------
No crash.

Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
0x0000000000aca980 in _object_and_properties_init (arg=0x7fffee415600, class_type=0x0, properties=0x0, __zend_filename=0xbba6e0 "/home/jost/php/php-7.1.5/ext/date/php_date.c", __zend_lineno=2541) at /home/jost/php/php-7.1.5/Zend/zend_API.c:1273
1273		if (UNEXPECTED(class_type->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) {
(gdb) bt
#0  0x0000000000aca980 in _object_and_properties_init (arg=0x7fffee415600, class_type=0x0, properties=0x0, __zend_filename=0xbba6e0 "/home/jost/php/php-7.1.5/ext/date/php_date.c", __zend_lineno=2541) at /home/jost/php/php-7.1.5/Zend/zend_API.c:1273
#1  0x0000000000acab7d in _object_init_ex (arg=0x7fffee415600, class_type=0x0, __zend_filename=0xbba6e0 "/home/jost/php/php-7.1.5/ext/date/php_date.c", __zend_lineno=2541) at /home/jost/php/php-7.1.5/Zend/zend_API.c:1310
#2  0x000000000044c6d9 in php_date_instantiate (pce=0x0, object=0x7fffee415600) at /home/jost/php/php-7.1.5/ext/date/php_date.c:2541
#3  0x0000000000453f91 in zim_DatePeriod_getStartDate (execute_data=0x7fffee4159a0, return_value=0x7fffee415600) at /home/jost/php/php-7.1.5/ext/date/php_date.c:4557
#4  0x0000000000b294f1 in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER () at /home/jost/php/php-7.1.5/Zend/zend_vm_execute.h:1097
#5  0x0000000000b2788d in execute_ex (ex=0x7fffee415030) at /home/jost/php/php-7.1.5/Zend/zend_vm_execute.h:429
#6  0x0000000000b2799e in zend_execute (op_array=0x7fffee489000, return_value=0x0) at /home/jost/php/php-7.1.5/Zend/zend_vm_execute.h:474
#7  0x0000000000ac49e2 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/jost/php/php-7.1.5/Zend/zend.c:1476
#8  0x0000000000a2a423 in php_execute_script (primary_file=0x7fffffffca90) at /home/jost/php/php-7.1.5/main/main.c:2537
#9  0x0000000000bae804 in do_cli (argc=2, argv=0x1539a80) at /home/jost/php/php-7.1.5/sapi/cli/php_cli.c:993
#10 0x0000000000baf9d7 in main (argc=2, argv=0x1539a80) at /home/jost/php/php-7.1.5/sapi/cli/php_cli.c:1381


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-26 10:59 UTC] andrew dot nester dot dev at gmail dot com
Thanks for reporting this issue.
I've just added PR implementing proper cloning logic.
 [2017-05-26 12:47 UTC] cmb@php.net
Related to bug #50559.
 [2017-06-01 07:08 UTC] krakjoe@php.net
Automatic comment on behalf of andrew.nester.dev@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=48598a23024eb587127b59bf0490891addfc41ed
Log: Fixed #74639 - Added proper clone functionality for DatePeriod and DateInterval
 [2017-06-01 07:08 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Mon Jul 24 10:01:45 2017 UTC