Bug #70546 [NEW]: ext/sysvshm: two broken tests on Solaris

From: Date: Mon, 21 Sep 2015 14:40:31 +0000
Subject: Bug #70546 [NEW]: ext/sysvshm: two broken tests on Solaris
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196132@lists.php.net to get a copy of this message
From:             rainer dot jung at kippdata dot de
Operating system: Solaris
PHP version:      7.0.0RC3
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:ext/sysvshm: two broken tests on Solaris

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 bug report at https://bugs.php.net/bug.php?id=70546&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70546&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70546&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70546&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70546&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70546&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70546&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70546&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70546&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70546&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70546&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70546&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70546&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70546&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70546&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70546&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70546&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70546&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70546&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70546&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70546&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#196132) next »