php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46108 DateTime - Memory leak when unserializing
Submitted: 2008-09-17 16:30 UTC Modified: 2009-04-07 20:05 UTC
From: felipe@php.net Assigned: derick
Status: Closed Package: Date/time related
PHP Version: 5.3CVS-2008-11-11 OS: *
Private report: No CVE-ID:
 [2008-09-17 16:30 UTC] felipe@php.net
Description:
------------
See below.

Reproduce code:
---------------
<?php

unserialize(serialize(new Datetime));

Actual result:
--------------
==18547== 51 bytes in 1 blocks are definitely lost in loss record 8 of 13
==18547==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==18547==    by 0x80C1A51: timelib_parse_tzfile (parse_tz.c:207)
==18547==    by 0x80A01DB: php_date_parse_tzfile (php_date.c:904)
==18547==    by 0x80A259F: get_timezone_info (php_date.c:1004)
==18547==    by 0x80A33FB: date_initialize (php_date.c:2443)
==18547==    by 0x80A3810: zim_DateTime___construct (php_date.c:2525)
==18547==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==18547==    by 0x83E9602: execute (zend_vm_execute.h:104)
==18547==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==18547==    by 0x836916C: php_execute_script (main.c:2080)
==18547==    by 0x845B734: main (php_cli.c:1130)
==18547== 
==18547== 
==18547== 120 bytes in 2 blocks are indirectly lost in loss record 9 of 13
==18547==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==18547==    by 0x80C279F: timelib_tzinfo_clone (timelib.c:116)
==18547==    by 0x80A9C40: timelib_fill_holes (parse_date.re:2111)
==18547==    by 0x80A32F9: date_initialize (php_date.c:2463)
==18547==    by 0x80A3810: zim_DateTime___construct (php_date.c:2525)
==18547==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==18547==    by 0x83E9602: execute (zend_vm_execute.h:104)
==18547==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==18547==    by 0x836916C: php_execute_script (main.c:2080)
==18547==    by 0x845B734: main (php_cli.c:1130)
==18547== 
==18547== 
==18547== 1,614 (152 direct, 1,462 indirect) bytes in 2 blocks are definitely lost in loss record 10 of 13
==18547==    at 0x402095F: calloc (vg_replace_malloc.c:279)
==18547==    by 0x80C26DA: timelib_tzinfo_ctor (timelib.c:95)
==18547==    by 0x80C2714: timelib_tzinfo_clone (timelib.c:103)
==18547==    by 0x80A9C40: timelib_fill_holes (parse_date.re:2111)
==18547==    by 0x80A32F9: date_initialize (php_date.c:2463)
==18547==    by 0x80A3810: zim_DateTime___construct (php_date.c:2525)
==18547==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==18547==    by 0x83E9602: execute (zend_vm_execute.h:104)
==18547==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==18547==    by 0x836916C: php_execute_script (main.c:2080)
==18547==    by 0x845B734: main (php_cli.c:1130)
==18547== 
==18547== 
==18547== 256 bytes in 2 blocks are indirectly lost in loss record 11 of 13
==18547==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==18547==    by 0x80C2756: timelib_tzinfo_clone (timelib.c:112)
==18547==    by 0x80A9C40: timelib_fill_holes (parse_date.re:2111)
==18547==    by 0x80A32F9: date_initialize (php_date.c:2463)
==18547==    by 0x80A3597: php_date_initialize_from_hash (php_date.c:2566)
==18547==    by 0x80A368D: zim_DateTime___wakeup (php_date.c:2607)
==18547==    by 0x83B8A1E: zend_call_function (zend_execute_API.c:907)
==18547==    by 0x83B9666: call_user_function_ex (zend_execute_API.c:681)
==18547==    by 0x832EC41: php_var_unserialize (var_unserializer.re:377)
==18547==    by 0x831AC86: zif_unserialize (var.c:866)
==18547==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==18547==    by 0x83E9602: execute (zend_vm_execute.h:104)
==18547==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==18547==    by 0x836916C: php_execute_script (main.c:2080)
==18547==    by 0x845B734: main (php_cli.c:1130)
==18547== 
==18547== 
==18547== 1,024 bytes in 2 blocks are indirectly lost in loss record 12 of 13
==18547==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==18547==    by 0x80C2748: timelib_tzinfo_clone (timelib.c:111)
==18547==    by 0x80A9C40: timelib_fill_holes (parse_date.re:2111)
==18547==    by 0x80A32F9: date_initialize (php_date.c:2463)
==18547==    by 0x80A3810: zim_DateTime___construct (php_date.c:2525)
==18547==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==18547==    by 0x83E9602: execute (zend_vm_execute.h:104)
==18547==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==18547==    by 0x836916C: php_execute_script (main.c:2080)
==18547==    by 0x845B734: main (php_cli.c:1130)
==18547== 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-11 10:38 UTC] jani@php.net
Note: PHP_5_3 only (and propably HEAD, I didn't test that)
 [2009-03-24 16:46 UTC] felipe@php.net
Here's a possible fix: http://felipe.ath.cx/diff/bug46108.diff
 [2009-04-07 20:05 UTC] felipe@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-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 18:02:13 2014 UTC