mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.3'
* PHP-8.3: Fix GH-14537: shmop Windows 11 crashes the process
This commit is contained in:
commit
d883996326
2 changed files with 30 additions and 2 deletions
|
@ -710,6 +710,7 @@ TSRM_API int shmget(key_t key, size_t size, int flags)
|
||||||
CloseHandle(shm->segment);
|
CloseHandle(shm->segment);
|
||||||
}
|
}
|
||||||
UnmapViewOfFile(shm->descriptor);
|
UnmapViewOfFile(shm->descriptor);
|
||||||
|
shm->descriptor = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,8 +746,8 @@ TSRM_API int shmdt(const void *shmaddr)
|
||||||
shm->descriptor->shm_lpid = getpid();
|
shm->descriptor->shm_lpid = getpid();
|
||||||
shm->descriptor->shm_nattch--;
|
shm->descriptor->shm_nattch--;
|
||||||
|
|
||||||
ret = 1;
|
ret = 0;
|
||||||
if (!ret && shm->descriptor->shm_nattch <= 0) {
|
if (shm->descriptor->shm_nattch <= 0) {
|
||||||
ret = UnmapViewOfFile(shm->descriptor) ? 0 : -1;
|
ret = UnmapViewOfFile(shm->descriptor) ? 0 : -1;
|
||||||
shm->descriptor = NULL;
|
shm->descriptor = NULL;
|
||||||
}
|
}
|
||||||
|
|
27
ext/shmop/tests/gh14537.phpt
Normal file
27
ext/shmop/tests/gh14537.phpt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--TEST--
|
||||||
|
GH-14537: shmop Windows 11 crashes the process
|
||||||
|
--EXTENSIONS--
|
||||||
|
shmop
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (PHP_OS_FAMILY !== 'Windows') die('skip only for Windows');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$str = 'Hello World';
|
||||||
|
|
||||||
|
$shm_key = ftok(__FILE__, 'p');
|
||||||
|
|
||||||
|
$shm_id1 = shmop_open($shm_key, 'c', 0644, strlen($str));
|
||||||
|
shmop_delete($shm_id1);
|
||||||
|
var_dump($shm_id1);
|
||||||
|
|
||||||
|
$shm_id2 = shmop_open($shm_key, 'c', 0644, strlen($str) + 10);
|
||||||
|
var_dump($shm_id2);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
object(Shmop)#1 (0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Warning: shmop_open(): Unable to attach or create shared memory segment "No error" in %s on line %d
|
||||||
|
bool(false)
|
Loading…
Add table
Add a link
Reference in a new issue