Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3659,6 +3659,7 @@ int zend_jit_check_support(void)

void zend_jit_startup(void *buf, size_t size, bool reattached)
{
ZEND_ASSERT(((uintptr_t)buf & (zend_get_page_size() - 1)) == 0);
zend_jit_halt_op = zend_get_halt_op();
zend_jit_profile_counter_rid = zend_get_op_array_extension_handle(ACCELERATOR_PRODUCT_NAME);

Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/shared_alloc_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_
}

shared_segment->pos = ACCEL_BASE_POINTER_SIZE;
shared_segment->size = requested_size - ACCEL_BASE_POINTER_SIZE;
shared_segment->size = requested_size;

zend_shared_alloc_unlock_win32();

Expand Down
53 changes: 53 additions & 0 deletions ext/opcache/tests/jit/gh25213.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
--TEST--
GH-25213 (JIT buffer misalignment crashes OPcache when shared memory fills up on Windows)
--EXTENSIONS--
opcache
--SKIPIF--
<?php
if (PHP_OS_FAMILY !== 'Windows') die('skip Windows only');
if (ini_get('opcache.jit') === false) die('skip PHP is compiled without JIT');
?>
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=16
opcache.interned_strings_buffer=1
opcache.max_accelerated_files=20000
opcache.jit=tracing
opcache.jit_buffer_size=64M
--FILE--
<?php
if (!(opcache_get_status(false)['jit']['enabled'] ?? false)) {
throw new RuntimeException('JIT is not enabled');
}
$dir = __DIR__ . '/gh25213_tmp';
mkdir($dir);
for ($i = 0; $i < 20000; $i++) {
$file = "$dir/c$i.php";
file_put_contents($file, "<?php class C$i extends ArrayObject { public function m(int \$a): int { return \$a + $i; } }\n");
require $file;
unlink($file);
$status = opcache_get_status(false);
if ($status['cache_full']) {
break;
}
}
var_dump($status['cache_full']);
var_dump($status['memory_usage']['free_memory'] < 65536);
var_dump($status['opcache_statistics']['num_cached_keys'] < $status['opcache_statistics']['max_cached_keys']);
rmdir($dir);
?>
--CLEAN--
<?php
$dir = __DIR__ . '/gh25213_tmp';
if (is_dir($dir)) {
foreach (glob("$dir/*") as $file) {
unlink($file);
}
rmdir($dir);
}
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
Loading