com php-src: fix FCGI crash in TS mode: sapi/cgi/cgi_main.c
| From: | Anatol Belski | Date: | Mon, 29 Jun 2015 05:33:19 +0000 |
| Subject: | com php-src: fix FCGI crash in TS mode: sapi/cgi/cgi_main.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87589@lists.php.net to get a copy of this message | ||
Commit: 8430ec1788350fc45bcb2d209ff8696972ca12d1
Author: Anatol Belski <ab@php.net> Sun, 28 Jun 2015 21:47:02 +0200
Parents: b34f9bc2e9df124c790d14b98c7746246d108e3d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8430ec1788350fc45bcb2d209ff8696972ca12d1
Log:
fix FCGI crash in TS mode
If CGI TS build is used, and there are some hard errors (fe missing
dependency .dll or .so), the core will want to log it. The CGI
log function will want to check whether fcgi_logging is enabled. But,
if this kind of error happens in the extension register phase,
MINIT for the CGI module is most likely wasn't run yet (startup phase).
That will result in accessing uninitialized globals and a crash.
Changed paths:
M sapi/cgi/cgi_main.c
Diff:
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 73b9d77..529824b 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -1470,11 +1470,6 @@ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals)
*/
static PHP_MINIT_FUNCTION(cgi)
{
-#ifdef ZTS
- ts_allocate_id(&php_cgi_globals_id, sizeof(php_cgi_globals_struct), (ts_allocate_ctor)
php_cgi_globals_ctor, NULL);
-#else
- php_cgi_globals_ctor(&php_cgi_globals);
-#endif
REGISTER_INI_ENTRIES();
return SUCCESS;
}
@@ -1778,6 +1773,12 @@ int main(int argc, char *argv[])
ZEND_TSRMLS_CACHE_UPDATE();
#endif
+#ifdef ZTS
+ ts_allocate_id(&php_cgi_globals_id, sizeof(php_cgi_globals_struct), (ts_allocate_ctor)
php_cgi_globals_ctor, NULL);
+#else
+ php_cgi_globals_ctor(&php_cgi_globals);
+#endif
+
sapi_startup(&cgi_sapi_module);
fastcgi = fcgi_is_fastcgi();
cgi_sapi_module.php_ini_path_override = NULL;