Skip to content

Commit daf0c95

Browse files
committed
Fix bug #76895
There are two parts here: First, opcache should not be blocking signals while invoking compile_file. Second, we should have noticed this issue a long time ago, but apparently we don't use zend_signal_deactivate as part of the standard shutdown sequence. In addition to calling deactivate, also make sure that we always check for zero depth, independent of SIGG(check), which is currently not enabled.
1 parent 8f384be commit daf0c95

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Zend/zend_signal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,14 @@ void zend_signal_activate(void)
336336
* */
337337
void zend_signal_deactivate(void)
338338
{
339+
if (SIGG(depth) != 0) {
340+
zend_error(E_CORE_WARNING, "zend_signal: shutdown with non-zero blocking depth (%d)", SIGG(depth));
341+
}
339342

340343
if (SIGG(check)) {
341344
size_t x;
342345
struct sigaction sa;
343346

344-
if (SIGG(depth) != 0) {
345-
zend_error(E_CORE_WARNING, "zend_signal: shutdown with non-zero blocking depth (%d)", SIGG(depth));
346-
}
347347
/* did anyone steal our installed handler */
348348
for (x = 0; x < sizeof(zend_sigs) / sizeof(*zend_sigs); x++) {
349349
sigaction(zend_sigs[x], NULL, &sa);

ext/opcache/ZendAccelerator.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2003,11 +2003,14 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
20032003
return accelerator_orig_compile_file(file_handle, type);
20042004
}
20052005

2006+
HANDLE_UNBLOCK_INTERRUPTIONS();
2007+
persistent_script = opcache_compile_file(file_handle, type, key, &op_array);
2008+
HANDLE_BLOCK_INTERRUPTIONS();
2009+
20062010
/* Try and cache the script and assume that it is returned from_shared_memory.
20072011
* If it isn't compile_and_cache_file() changes the flag to 0
20082012
*/
20092013
from_shared_memory = 0;
2010-
persistent_script = opcache_compile_file(file_handle, type, key, &op_array);
20112014
if (persistent_script) {
20122015
persistent_script = cache_script_in_shared_memory(persistent_script, key, key ? key_length : 0, &from_shared_memory);
20132016
}

main/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,11 @@ void php_request_shutdown(void *dummy)
19321932
zend_unset_timeout();
19331933
} zend_end_try();
19341934

1935+
/* 17. Deactivate Zend signals */
1936+
#ifdef ZEND_SIGNALS
1937+
zend_signal_deactivate();
1938+
#endif
1939+
19351940
#ifdef PHP_WIN32
19361941
if (PG(com_initialized)) {
19371942
CoUninitialize();

0 commit comments

Comments
 (0)