|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-12-08 21:04 UTC] jsheridan at tenable dot com
Description:
------------
strtotime calls with a timezone embedded function correctly but continually use up
memory. In a daemon program this becomes quickly fatal.
Test script:
---------------
<?php
while (true) {
strtotime('Monday 00:00 Europe/Paris'); // Memory leak
}
?>
<?php
while (true) {
date_default_timezone_set("Europe/Paris");
strtotime('Monday 00:00'); // No memory leak
}
?>
Expected result:
----------------
Memory usage should remain stable.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 05:00:01 2025 UTC |
Timezone identifier parsing initiated by the timelib is not tracked by the caching mechanism of php_date_parse_tzfile and ends up leaked. The illustrate this, running php -d date.timezone="Europe/Lisbon" -r "echo strtotime('Monday 00:00 Europe/Paris');" gives these distinct backtraces in one of the functions were leaked memory is allocated: #0 read_transistions (tzf=0x7fff5facace0, tz=0x7fbbace67fe8) at /home/glopes/php/php-trunk/ext/date/lib/parse_tz.c:86 #1 0x0000000000459563 in timelib_parse_tzfile ( timezone=0x27f7ee0 "Europe/Lisbon", tzdb=0x8558a0) at /home/glopes/php/php-trunk/ext/date/lib/parse_tz.c:322 #2 0x00000000004215ef in php_date_parse_tzfile ( formal_tzname=0x27f7ee0 "Europe/Lisbon", tzdb=0x8558a0) at /home/glopes/php/php-trunk/ext/date/php_date.c:829 #3 0x0000000000421923 in get_timezone_info () at /home/glopes/php/php-trunk/ext/date/php_date.c:939 #4 0x0000000000423ed8 in zif_strtotime (ht=1, return_value=0x7fbbace65e40, return_value_ptr=0x0, this_ptr=0x0, return_value_used=1) at /home/glopes/php/php-trunk/ext/date/php_date.c:1396 #0 read_transistions (tzf=0x7fff5facab10, tz=0x7fbbace68858) at /home/glopes/php/php-trunk/ext/date/lib/parse_tz.c:86 #1 0x0000000000459563 in timelib_parse_tzfile ( timezone=0x7fbbace687f0 "Europe/Paris", tzdb=0x8558a0) at /home/glopes/php/php-trunk/ext/date/lib/parse_tz.c:322 #2 0x0000000000431c37 in timelib_get_zone (ptr=0x7fff5facac40, dst=0x7fbbace685d8, t=0x7fbbace68588, tz_not_found=0x7fff5facac3c, tzdb=0x8558a0) at /home/glopes/php/php-trunk/ext/date/lib/parse_date.c:808 #3 0x0000000000431f90 in scan (s=0x7fff5facad00) at /home/glopes/php/php-trunk/ext/date/lib/parse_date.c:1009 #4 0x0000000000456f07 in timelib_strtotime ( s=0x7fbba90ed708 "Monday 00:00 Europe/Paris", len=25, errors=0x7fff5facadd8, tzdb=0x8558a0) at /home/glopes/php/php-trunk/ext/date/lib/parse_date.c:24690 #5 0x00000000004240f9 in zif_strtotime (ht=1, return_value=0x7fbbace65e40, return_value_ptr=0x0, this_ptr=0x0, return_value_used=1) at /home/glopes/php/php-trunk/ext/date/php_date.c:1426I can also reproduce it with: for($i=0;$i<100000;++$i) { new DateTime('UTC'); }