|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesphp-sysvshm-shm_remove-twice (last revision 2015-09-21 14:42 UTC by rainer dot jung at kippdata dot de)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-09-22 04:07 UTC] laruence@php.net
[2015-09-22 04:07 UTC] laruence@php.net
-Status: Open
+Status: Closed
[2015-09-29 13:10 UTC] ab@php.net
[2016-07-20 11:36 UTC] davey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 13:00:01 2025 UTC |
Description: ------------ Tests ext/sysvshm/tests/002.phpt and ext/sysvshm/tests/007.phpt are both broken on Solaris. Solaris does not allow to remove a shred memory segment twice in the same process. So when doing two calls to shm_remove() for the same segment, the second fails with errno 22 (Invalid argument). This can easily be reproduced using a simple C program. On linux calling shm_remove() twice is allowed. The standards docs for shmctl with param IPC_RMID (that is what sits underneath PHP shm_remove()) say: <quote>Remove the shared memory identifier specified by shmid from the system and destroy the shared memory segment and shmid_ds data structure associated with it. IPC_RMID can only be executed by a process that has an effective user ID equal to either that of a process with appropriate privileges or to the value of shm_perm.cuid or shm_perm.uid in the shmid_ds data structure associated with shmid.</quote> So IMHO the linux behavior is more luck than expected. The problem shows up in ext/sysvshm/tests/002.phpt, failing because of the output Warning: shm_remove(): failed for key 0x7406e291, id -37354056: Invalid argument in /path/to/ext/sysvshm/tests/002.php on line 21 I think that failure might be actually side effect of a typo. The test contains: 19 var_dump($s = shm_attach($key, -1)); 20 shm_remove($s); 21 var_dump(shm_attach($key, 0)); 22 shm_remove($s); and if you alter it to 19 var_dump($s = shm_attach($key, -1)); 20 shm_remove($s); 21 var_dump($s = shm_attach($key, 0)); 22 shm_remove($s); (adding "$s = " for the second shm_attach) the test passes. The second failing test is ext/sysvshm/tests/007.phpt. The message is Warning: shm_remove(): failed for key 0x7406ef15, id -37354344: Invalid argument in /path/to/ext/sysvshm/tests/007.php on line 12 and the problem is: 10 11 var_dump(shm_remove($s)); 12 var_dump(shm_remove($s)); 13 so the test tries to remove the same shm twice. That might be intended, but it is not guaranteed to work on all platforms. I don't actually see a reason for that part of the test, so I suggets to drop line 12. Please see the attached patch with the fixes for the two tests. The problem and patch applies to the latest releases of PHP 5.4-5.6 and 7 RC 3.