From: Aaron Bannert Date: Sun, 5 May 2002 18:11:41 +0000 (+0000) Subject: Fix an elusive and intermittent startup SEGV. The problem was X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~218 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b759322411220e9c165776be743700b8799ffec2;p=php Fix an elusive and intermittent startup SEGV. The problem was the static string we were using to set an initialization flag would get remapped to a different location when Apache reloaded the DSO, causing us to not run our initialization routines. Submitted by: Justin Erenkrantz Reviewed by: Aaron Bannert (I added the big comment too) --- diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index e512a89e8f..81f3fd6d0e 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -454,14 +454,19 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, * prevents us from starting PHP until the second load. */ apr_pool_userdata_get(&data, userdata_key, s->process->pool); if (data == NULL) { - apr_pool_userdata_setn((const void *)1, userdata_key, - apr_pool_cleanup_null, s->process->pool); + /* We must use set() here and *not* setn(), otherwise the + * static string pointed to by userdata_key will be mapped + * to a different location when the DSO is reloaded and the + * pointers won't match, causing get() to return NULL when + * we expected it to return non-NULL. */ + apr_pool_userdata_set((const void *)1, userdata_key, + apr_pool_cleanup_null, s->process->pool); return OK; } else if (data == (const void *)2) { return OK; } - apr_pool_userdata_setn((const void *)2, userdata_key, + apr_pool_userdata_set((const void *)2, userdata_key, apr_pool_cleanup_null, s->process->pool); /* Set up our overridden path. */