Bug #70546 [Opn->Csd]: ext/sysvshm: two broken tests on Solaris

From: Date: Tue, 22 Sep 2015 04:07:08 +0000
Subject: Bug #70546 [Opn->Csd]: ext/sysvshm: two broken tests on Solaris
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196149@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70546&edit=1 ID: 70546 Updated by: laruence@php.net Reported by: rainer dot jung at kippdata dot de Summary: ext/sysvshm: two broken tests on Solaris -Status: Open +Status: Closed Type: Bug Package: Unknown/Other Function Operating System: Solaris PHP Version: 7.0.0RC3 Block user comment: N Private report: N New Comment: Automatic comment on behalf of laruence@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=b8ea991821753898ba30fa170b25eadd3fc703b2 Log: Fixed bug #70546 (ext/sysvshm: two broken tests on Solaris) by rainer.jung Previous Comments: ------------------------------------------------------------------------ [2015-09-21 14:40:29] rainer dot jung at kippdata dot de 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70546&edit=1

« previous php.bugs (#196149) next »