php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48247 PHP crashes on errors during startup
Submitted: 2009-05-12 16:09 UTC Modified: 2009-07-07 16:43 UTC
From: dmitry@php.net Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.*, 6CVS (2009-05-12) OS: *
Private report: No CVE-ID: None
 [2009-05-12 16:09 UTC] dmitry@php.net
Description:
------------
PHP crashes in case of warning messages during MINIT().

In case of warning messages during MINIT() the php_log_err() function is called. In case error_log directive is set to log errors into file this function tries to add timestamp using formatting through php_format_date(). However it leads PHP into infinity recursion if TZ isn't set, because php_format_date() throws another warning.

Even preventing the recursion with static flag makes PHP crash in ext/date because of uninitialized DATEG(tzcache).

#0  0x084922d2 in zend_hash_find (ht=0x89e9ac8, 
    arKey=0x857edbd "Europe/Moscow", nKeyLength=14, pData=0xffffceac)
    at /home/dmitry/php/php5.3/Zend/zend_hash.c:880
#1  0x08142ff1 in php_date_parse_tzfile (
    formal_tzname=0x857edbd "Europe/Moscow", tzdb=0x85cb9c8)
    at /home/dmitry/php/php5.3/ext/date/php_date.c:813
#2  0x081432a9 in get_timezone_info ()
    at /home/dmitry/php/php5.3/ext/date/php_date.c:917
#3  0x08144d8c in php_format_date (format=0x899b203 "d-M-Y H:i:s", 
    format_len=11, ts=1242143549, localtime=1)
    at /home/dmitry/php/php5.3/ext/date/php_date.c:1166
#4  0x08415f16 in php_log_err (
    log_message=0xf7f8f678 "PHP Warning:  test in Unknown on line 0")
    at /home/dmitry/php/php5.3/main/main.c:547
#5  0x08416db9 in php_error_cb (type=2, error_filename=0x89b00cf "Unknown", 
    error_lineno=0, format=0x899bb97 "test", args=0xffffd088 "\005")
    at /home/dmitry/php/php5.3/main/main.c:958
#6  0x084832d2 in zend_error (type=2, format=0x899bb97 "test")
    at /home/dmitry/php/php5.3/Zend/zend.c:1020
#7  0x08418ecf in php_module_startup (sf=0x89d11a0, additional_modules=0x0, 
    num_additional_modules=0) at /home/dmitry/php/php5.3/main/main.c:2021
#8  0x08546f59 in php_cli_startup (sapi_module=0x89d11a0)
    at /home/dmitry/php/php5.3/sapi/cli/php_cli.c:399



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-12 16:31 UTC] jani@php.net
See also bug #37111 which is similar problem, just during shutdown.
 [2009-05-12 17:11 UTC] jani@php.net
And of course this problem exists in all branches.
 [2009-05-13 00:46 UTC] jani@php.net
Dmitry, I committed a fix in HEAD. Please check it out. If you agree, 
I'll MFH to other branches.
 [2009-05-13 07:09 UTC] dmitry@php.net
Unfortunately this patch doesn't fix the bug.
 [2009-05-13 18:21 UTC] jani@php.net
I fixed the first part (dependancy issues + loading order), Derick can 
now fix the second part and add infinite recursion protection and make 
init tzcache be done in GINIT _and_ RINIT (if ! init -> init.. :)
 [2009-05-31 21:32 UTC] stas@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.

Should be fixed now in 5.2+
 [2009-06-16 17:38 UTC] stas@php.net
See also bug #48534
 [2009-07-07 15:46 UTC] jani@php.net
This really need to be fixed ASAP! There was some patch by Stas somewhere, why it isn't committed is a mystery..
 [2009-07-07 16:30 UTC] jani@php.net
Can't find Stas' patch, but here's my proposal:

  http://pecl.php.net/~jani/patches/bug48247.patch

I don't see any reason why possible startup errors need to have "properly formatted" error especially when the error is about the formatting of that date. :D
 [2009-07-07 16:43 UTC] jani@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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC