Bug #73005 [NEW]: In child process overdo call sem_release resulting max_acquire overflow
| From: | consatan at gmail dot com | Date: | Fri, 02 Sep 2016 18:35:58 +0000 |
| Subject: | Bug #73005 [NEW]: In child process overdo call sem_release resulting max_acquire overflow | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-203754@lists.php.net to get a copy of this message | ||
From: consatan at gmail dot com
Operating system: Unix like OS
PHP version: Irrelevant
Package: Semaphore related
Bug Type: Bug
Bug description:In child process overdo call sem_release resulting max_acquire overflow
Description:
------------
Test in
OS: Debian 8.5 and CentOS 7.2.1511
PHP: 5.6.25 and 7.0.10
configure: --enable-pcntl --enable-sysvshm --enable-sysvsem
--enable-sysvmsg
Look like the semaphore resource in each child process is an clone not a
reference.
The semaphore resources state in child process was cloned from the last
state before parent process triggered pcntl_fork().
Test script:
---------------
<?php
$ipcs = "ipcs -s -i
ipcs -s | grep 0x0001e240 | awk '{print $2}' | awk
'NR==9'";
$sem = sem_get(123456, 3, 0666, 0);
echo exec($ipcs) . " first\n";
for ($i = 0; $i < 3; $i++) {
sem_acquire($sem);
if (pcntl_fork() === 0) {
echo exec($ipcs) . " $i start\n";
for ($j = 0; $j < 3; $j++) sem_release($sem);
echo exec($ipcs) . " $i end\n";
exit(0);
}
}
usleep(50000);
echo exec($ipcs) . " last\n";
sem_remove($sem);
Expected result:
----------------
6 times Warning
semaphore's max_acquirce <= 3
Actual result:
--------------
0 3 0 0 7128 first
0 0 0 0 7128 2 start
0 3 0 0 7138 1 start
Warning: sem_release(): SysV semaphore 4 (key 0x1e240) is not currently
acquired in /tmp/sem.php on line 10
0 5 0 0 7137 0 start
Warning: sem_release(): SysV semaphore 4 (key 0x1e240) is not currently
acquired in /tmp/sem.php on line 10
Warning: sem_release(): SysV semaphore 4 (key 0x1e240) is not currently
acquired in /tmp/sem.php on line 10
0 6 0 0 7136 1 end
0 4 0 0 7137 2 end
0 1 0 0 7138 0 end
0 0 0 0 7136 last
--
Edit bug report at https://bugs.php.net/bug.php?id=73005&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73005&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73005&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73005&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73005&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73005&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73005&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73005&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73005&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73005&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73005&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73005&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73005&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73005&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73005&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73005&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73005&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73005&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73005&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73005&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73005&r=mysqlcfg