Skip to content

Commit

Permalink
Here is the real elimination of the segmentation-fault on shutdown af…
Browse files Browse the repository at this point in the history
…ter 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.
  • Loading branch information
zenovich committed Nov 5, 2009
1 parent f79e12e commit ffa9a18
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions runkit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ffa9a18

Please sign in to comment.