From ffa9a187c6ac2d14244b766fd58581cff1d0a975 Mon Sep 17 00:00:00 2001 From: Dmitry Zenovich Date: Thu, 5 Nov 2009 19:48:32 +0300 Subject: [PATCH] Here is the real elimination of the segmentation-fault on shutdown after restoring modified internal functions. This problem was fully described here http://pecl.php.net/bugs/bug.php?id=11632 but I see this bug occurs only after the second request to the test-page through fascgi (on the same worker process) or results in crash in cli mode for the each test execution. The solution is to remove all user-defined functions out of the executor's global function table in a request shutdown function. --- runkit.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/runkit.c b/runkit.c index 60ac63a..a4121e9 100644 --- a/runkit.c +++ b/runkit.c @@ -358,6 +358,18 @@ static int php_runkit_superglobal_dtor(char *pDest TSRMLS_DC) /* }}} */ #endif /* PHP_RUNKIT_SUPERGLOBALS */ +/* {{{ php_runkit_delete_user_functions */ +int php_runkit_delete_user_functions(void *pDest TSRMLS_DC) +{ + if (pDest == NULL || + ((zend_function*)pDest)->type != ZEND_INTERNAL_FUNCTION) { + return ZEND_HASH_APPLY_REMOVE; + } + + return ZEND_HASH_APPLY_KEEP; +} +/* }}} */ + /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(runkit) @@ -387,6 +399,8 @@ PHP_RSHUTDOWN_FUNCTION(runkit) FREE_HASHTABLE(RUNKIT_G(replaced_internal_functions)); RUNKIT_G(replaced_internal_functions) = NULL; } + + zend_hash_apply(EG(function_table), php_runkit_delete_user_functions); #endif /* PHP_RUNKIT_MANIPULATION */ return SUCCESS;