[php-src] Issue #14537: shmop

From: Date: Tue, 11 Jun 2024 07:01:41 +0000
Subject: [php-src] Issue #14537: shmop
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-247071@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/14537 Author: EdmondDantes ### Description Description: An attempt to allocate a memory block with the same key but a larger size after proper deallocation causes a memory violation and crashes the process. The following code: ```php <?php declare(strict_types=1); $str = 'Hello World'; $shm_key = ftok(__FILE__, 'p'); $shm_id1 = shmop_open($shm_key, 'c', 0644, strlen($str)); shmop_delete($shm_id1); $shm_id2 = shmop_open($shm_key, 'c', 0644, strlen($str) + 10); // ^ -- This is the difference if ($shm_id2) { shmop_write($shm_id2, $str, 0); } else throw new RuntimeException("Couldn't create shared memory segment."); ``` Resulted in this output: ``` Warning: shmop_open(): Unable to attach or create shared memory segment "No error" in C:\work\ct\cluster\test.php on line 11 PHP Warning: shmop_open(): Unable to attach or create shared memory segment "No error" in C:\work\ct\cluster\test.php on line 11 Process finished with exit code -1073741819 (0xC0000005) // Memory crached ``` But I expected this output instead: ``` All should be OK ``` ### PHP Version PHP 8.3.4 ### Operating System Windows 11

« previous php.bugs (#247071) next »