php-src/ext/opcache
Niels Dossche 7869af6fa8
Fix GH-18417: Windows SHM reattachment fails when increasing memory_consumption or jit_buffer_size
When a first PHP process launches, Opcache creates a shared file mapping
to use as a shm region. The size of this mapping is set by
opcache.memory_consumption.
When a new PHP process launches while the old one is still running,
Opcache tries to reattach to the shm.
When reattaching it tries to map the requested size (i.e. set by
opcache.memory_consumption). However, if the new requested size is
larger than the size used in the original file mapping, then the call
to VirtualProtect() will fail and the new PHP process will fail to
launch.
It's not possible to resize the virtual region on Windows, unless
relying on undocumented APIs like `NtExtendSection` but then we would
sitll need to communicate that to the first process.

This issue is the root cause of Psalm end-to-end tests failing in
GH-18417: Psalm estimates the required memory sizes and relaunches itself
with more memory requested, if its estimate is below the currently allocated
shared memory. This causes a crash on startup and the tests fail.

To solve this, we need to make the mappings unique per requested size.
There are two ideas:
1. Include in zend_system_id. However, this also affects other things
   and may be too overkill.
2. Include it in the filename, this is an easy local change.
   I went with this option.

Closes GH-18443.
2025-04-28 19:51:31 +02:00
..
jit Correct check for maximum string length in JIT helpers 2025-03-13 23:47:45 +01:00
tests Fix GH-18417: Windows SHM reattachment fails when increasing memory_consumption or jit_buffer_size 2025-04-28 19:51:31 +02:00
config.m4 Merge branch 'PHP-8.2' into PHP-8.3 2024-07-22 06:58:01 +02:00
config.w32
CREDITS
opcache.stub.php
opcache_arginfo.h
shared_alloc_mmap.c Merge branch 'PHP-8.2' into PHP-8.3 2024-07-23 13:43:13 +02:00
shared_alloc_posix.c Make lots of string pointers const (#10646) 2023-02-21 14:01:37 +00:00
shared_alloc_shm.c Make lots of string pointers const (#10646) 2023-02-21 14:01:37 +00:00
shared_alloc_win32.c Fix GH-18417: Windows SHM reattachment fails when increasing memory_consumption or jit_buffer_size 2025-04-28 19:51:31 +02:00
zend_accelerator_blacklist.c Fix gcc-14 Wcalloc-transposed-args warnings 2024-04-01 20:34:14 +02:00
zend_accelerator_blacklist.h
zend_accelerator_debug.c
zend_accelerator_debug.h ext/opcache: C++ compatibility 2023-01-12 15:14:05 +00:00
zend_accelerator_hash.c Mark globals as const (#10303) 2023-01-23 13:46:58 +00:00
zend_accelerator_hash.h Revert GH-10279 2023-01-16 12:25:59 +01:00
zend_accelerator_module.c opcache_get_configuration() properly reports jit_prof_threshold 2024-12-09 11:45:16 +01:00
zend_accelerator_module.h
zend_accelerator_util_funcs.c Merge branch 'PHP-8.2' into PHP-8.3 2024-10-22 15:05:29 +02:00
zend_accelerator_util_funcs.h ext/opcache: C++ compatibility 2022-03-20 20:38:23 +01:00
zend_file_cache.c Merge branch 'PHP-8.2' into PHP-8.3 2023-10-11 09:57:43 +03:00
zend_file_cache.h ext/opcache: merge redundant code and "bool" refactoring (#8237) 2022-03-24 15:03:53 +01:00
zend_persist.c Merge branch 'PHP-8.2' into PHP-8.3 2024-08-30 01:01:22 +03:00
zend_persist.h ext/opcache: C++ compatibility 2023-01-12 15:14:05 +00:00
zend_persist_calc.c Merge branch 'PHP-8.2' into PHP-8.3 2024-05-06 16:02:20 +02:00
zend_shared_alloc.c Prevent possible incorrect optimization caused by ZEND_ASSUME() 2024-08-29 23:10:34 +03:00
zend_shared_alloc.h Merge branch 'PHP-8.2' into PHP-8.3 2023-10-23 10:51:59 +03:00
ZendAccelerator.c Fix GH-18112: NULL access with preloading and INI option 2025-03-20 19:12:06 +01:00
ZendAccelerator.h Fix inline zend_string using struct padding 2025-01-27 19:50:38 +01:00