Hi Jani,

Unfortunately this patch doesn't fix the bug.
I'm not sure if it fixes module dependency issues (let me know how to check it), but the original bug has the same two problems.


1) Possible infinity recursion in php_log_err()

2) Uninitialized DATEG(tzcache. It's initialized only during RINIT() so any error messages befor this may crash PHP.

To test it I just inserted a warning message into main.c around line 2130, right before module_initialized assignment.

+       zend_error(E_WARNING, "test");
        module_initialized = 1;

Then run something like this

$ sapi/cli/php -n -ddate.timezone= -derror_log=/tmp/php.log -r 'echo "ok\n";' /home/dmitry/php/php6/Zend/zend_hash.c(91) : Bailed out without a bailout address!

It may bailout or crash.

Thanks. Dmitry.







Jani Taskinen wrote:
jani            Wed May 13 00:45:57 2009 UTC

Added files: /php-src/ext/date config0.m4 Removed files: /php-src/ext/date config.m4 Modified files: /ZendEngine2 zend.c /php-src/build order_by_dep.awk /php-src/ext/date php_date.c Log:
  - Fixed bug #48247 (PHP crashes on errors during startup)
# # This was sum of many little things: # 1. Wrong assumption made in order_by_dep.awk on the ordering # (that script was done prior to adding runtime deps..?)
  # 2. request shutdown calls weren't done in reverse order like all other
  #    shutdown funcs are called.
  # 3. config0.m4 rename is necessary for keeping things simple.
  #
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.432&r2=1.433&diff_format=u
Index: ZendEngine2/zend.c
diff -u ZendEngine2/zend.c:1.432 ZendEngine2/zend.c:1.433
--- ZendEngine2/zend.c:1.432    Thu Mar 26 20:01:37 2009
+++ ZendEngine2/zend.c  Wed May 13 00:45:57 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
-/* $Id: zend.c,v 1.432 2009/03/26 20:01:37 felipe Exp $ */
+/* $Id: zend.c,v 1.433 2009/05/13 00:45:57 jani Exp $ */
#include "zend.h"
 #include "zend_extensions.h"
@@ -1418,7 +1418,7 @@
        EG(opline_ptr) = NULL; /* we're no longer executing anything */
zend_try {
-               zend_hash_apply(&module_registry, (apply_func_t) 
module_registry_cleanup TSRMLS_CC);
+               zend_hash_reverse_apply(&module_registry, (apply_func_t) 
module_registry_cleanup TSRMLS_CC);
        } zend_end_try();
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/build/order_by_dep.awk?r1=1.1&r2=1.2&diff_format=u
Index: php-src/build/order_by_dep.awk
diff -u php-src/build/order_by_dep.awk:1.1 php-src/build/order_by_dep.awk:1.2
--- php-src/build/order_by_dep.awk:1.1  Sun Jul 18 12:03:51 2004
+++ php-src/build/order_by_dep.awk      Wed May 13 00:45:57 2009
@@ -79,8 +79,7 @@
        out_count = 0;
        
        while (count(mods)) {
-               # count down, since we need to assemble it in reverse order
-               for (i = mod_count-1; i >= 0; --i) {
+               for (i = 0; i <= mod_count; i++) {
                        if (i in mods) {
                                do_deps(i);
                        }
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.230&r2=1.231&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.230 php-src/ext/date/php_date.c:1.231
--- php-src/ext/date/php_date.c:1.230   Tue May  5 12:34:03 2009
+++ php-src/ext/date/php_date.c Wed May 13 00:45:57 2009
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
-/* $Id: php_date.c,v 1.230 2009/05/05 12:34:03 iliaa Exp $ */
+/* $Id: php_date.c,v 1.231 2009/05/13 00:45:57 jani Exp $ */
#define _ISOC9X_SOURCE @@ -570,17 +570,11 @@
 zval *date_interval_read_property(zval *object, zval *member, int type 
TSRMLS_DC);
 void date_interval_write_property(zval *object, zval *member, zval *value 
TSRMLS_DC);
-/* This is need to ensure that session extension request shutdown occurs 1st, because it uses the date extension */ -static const zend_module_dep date_deps[] = {
-       ZEND_MOD_OPTIONAL("session")
-       {NULL, NULL, NULL}
-};
-
 /* {{{ Module struct */
 zend_module_entry date_module_entry = {
        STANDARD_MODULE_HEADER_EX,
        NULL,
-       date_deps,
+       NULL,
        "date",                     /* extension name */
        date_functions,             /* function list */
        PHP_MINIT(date),            /* process startup */

http://cvs.php.net/viewvc.cgi/php-src/ext/date/config0.m4?view=markup&rev=1.1
Index: php-src/ext/date/config0.m4
+++ php-src/ext/date/config0.m4
dnl $Id: config0.m4,v 1.1 2009/05/13 00:45:57 jani Exp $
dnl config.m4 for date extension

sinclude(ext/date/lib/timelib.m4)
sinclude(lib/timelib.m4)

PHP_DATE_CFLAGS="-...@ext_builddir@/lib"
timelib_sources="lib/astro.c lib/dow.c lib/parse_date.c lib/parse_tz.c lib/timelib.c lib/tm2unixtime.c lib/unixtime2tm.c lib/parse_iso_intervals.c lib/interval.c"

PHP_NEW_EXTENSION(date, php_date.c $timelib_sources, no,, $PHP_DATE_CFLAGS)

PHP_ADD_BUILD_DIR([$ext_builddir/lib], 1)
PHP_ADD_INCLUDE([$ext_builddir/lib])
PHP_ADD_INCLUDE([$ext_srcdir/lib])

PHP_INSTALL_HEADERS([ext/date], [php_date.h lib/timelib.h lib/timelib_structs.h 
lib/timelib_config.h])

cat > $ext_builddir/lib/timelib_config.h <<EOF
#ifdef PHP_WIN32
# include "config.w32.h"
#else
# include <php_config.h>
#endif
EOF




--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to