php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37968 Calling date related functions inside custom session handler functions
Submitted: 2006-06-30 03:57 UTC Modified: 2006-08-23 06:58 UTC
From: corey at motionworks dot com dot my Assigned: derick
Status: Closed Package: Reproducible crash
PHP Version: 5.1.4 OS: WinXP
Private report: No CVE-ID:
 [2006-06-30 03:57 UTC] corey at motionworks dot com dot my
Description:
------------
Using any of the following date functions inside a custom session handler function causes PHP (and associated Apache thread) to crash. Currently using PHP-CGI.

Functions:
date()
strtotime()
date_default_timezone_get()

time() - Works and doesnt't cause a crash

Reproduce code:
---------------
function sess_open($strSavePath, $strSessionName)
{
    return true;
}
function sess_close()
{
    return true;
}
function sess_read($strKey)
{
    return '';
}
function sess_write($strKey, $strVal)
{
    $strDate = date('d/m/Y H:i:s');
    return true;
}
function sess_destroy($strKey)
{
    return true;
}
function sess_gc($intMaxLifetime)
{
    return true;
}
session_set_save_handler(
            'sess_open',
            'sess_close',
            'sess_read',
            'sess_write',
            'sess_destroy',
            'sess_gc');
session_start();
sess_write('foo', 'bar');

Expected result:
----------------
It not to crash :-)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-30 07:12 UTC] derick@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
 [2006-06-30 09:07 UTC] corey at motionworks dot com dot my
I have installed the MVC and the call stack is:
PHP5TS! 1009c95f()

The exact error message is:
"Unhandled exception in php-cgi.exe (PHP5TS.DLL): 0xC0000005: Access Violation"


I dont think this is helpful :-)

Please note the code above should be:
$_SESSION['foo'] = 'bar';
instead of:
sess_write('foo', 'bar');
 [2006-06-30 09:13 UTC] corey at motionworks dot com dot my
Ok, obviously the dbg pack ist being picked up. (still working on it)
 [2006-06-30 09:20 UTC] derick@php.net
Ok, let's keep it set to feedback for now then.
 [2006-06-30 10:28 UTC] corey at motionworks dot com dot my
Ok, couldnt get the stack trace for 5.1.4, so I upgraded to 5.2-snapshot.

Same problem occurs and the stack trace is as follows:
zend_hash_find(_hashtable * 0x100f0602, char * 0x00eaa4e8, unsigned int 2278520, void * * 0x00000012) line 852
php_date_parse_tzfile(char * 0x0022c478, const _timelib_tzdb * 0x102f44c0 _timezonedb_builtin, void * * * 0x00222550) line 531 + 50 bytes
get_timezone_info(void * * * 0x00222550) line 628 + 25 bytes
php_format_date(char * 0x00e2c5e0, int 5, long 1151663143, int 1, void * * * 0x00222550) line 859
php_date(int 1151663143, _zval_struct * 0x00e2cdd8, _zval_struct * * 0x00000000, _zval_struct * 0x00000000, int 1, void * * * 0x00222550, int 1) line 845
zif_date(int 1, _zval_struct * 0x00e2cdd8, _zval_struct * * 0x00000000, _zval_struct * 0x00000000, int 1, void * * * 0x00222550) line 974 + 37 bytes
zend_do_fcall_common_helper_SPEC(_zend_execute_data * 0x1001fcf5, void * * * 0x00c0d89c) line 200 + 49 bytes
ZEND_DO_FCALL_SPEC_CONST_HANDLER(_zend_execute_data * 0x10019515, void * * * 0x00000000) line 1642 + 14 bytes
execute(_zend_op_array * 0x00c0da40, void * * * 0x00000000) line 92 + 12 bytes
00c0da40()
75db8504()
 [2006-07-30 17:42 UTC] zybersup at yahoo dot com
Another bug report which might be related and helpful.
http://bugs.php.net/bug.php?id=38263

(I found the same crash but it's just 90% happen, not reproducible always.)
 [2006-08-22 20:45 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-08-23 05:57 UTC] corey at motionworks dot com dot my
Tested on windows, zero problems. Thanks
 [2006-08-23 06:58 UTC] tony2001@php.net
Great, thanks.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 00:02:04 2014 UTC