PHP: fixed crash when calling module functions in OPcache preload.
In PHP, custom fastcgi_finish_request() and overloaded chdir() functions can be invoked by an OPcache preloading script (it runs when php_module_startup() is called in the app process setup handler). In this case, there was no runtime context set so trying to access it caused a segmentation fault. This closes #602 issue on GitHub.
This commit is contained in:
@@ -45,6 +45,13 @@ appeared in 1.26.0.
|
|||||||
</para>
|
</para>
|
||||||
</change>
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para>
|
||||||
|
a segmentation fault occurred in the PHP module if chdir() or
|
||||||
|
fastcgi_finish_request() was called in the OPcache preloading script.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
</changes>
|
</changes>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,10 @@ ZEND_NAMED_FUNCTION(nxt_php_chdir)
|
|||||||
nxt_php_run_ctx_t *ctx;
|
nxt_php_run_ctx_t *ctx;
|
||||||
|
|
||||||
ctx = SG(server_context);
|
ctx = SG(server_context);
|
||||||
|
|
||||||
|
if (nxt_fast_path(ctx != NULL)) {
|
||||||
ctx->chdir = 1;
|
ctx->chdir = 1;
|
||||||
|
}
|
||||||
|
|
||||||
nxt_php_chdir_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
nxt_php_chdir_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||||
}
|
}
|
||||||
@@ -225,7 +228,7 @@ PHP_FUNCTION(fastcgi_finish_request)
|
|||||||
|
|
||||||
ctx = SG(server_context);
|
ctx = SG(server_context);
|
||||||
|
|
||||||
if (nxt_slow_path(ctx->req == NULL)) {
|
if (nxt_slow_path(ctx == NULL || ctx->req == NULL)) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user