Bug #75415 [NEW]: shm_put_var() parallel bug.

From: Date: Sun, 22 Oct 2017 10:04:45 +0000
Subject: Bug #75415 [NEW]: shm_put_var() parallel bug.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211818@lists.php.net to get a copy of this message
From:             abc905 at mail dot ru
Operating system: Linux Debian 4.9.0-4-amd64
PHP version:      7.1.10
Package:          Semaphore related
Bug Type:         Bug
Bug description:shm_put_var() parallel bug.

Description:
------------
Run test script 1-10 times to see that in spite of the fact 
shm_put_var returns true, shm_has_var() returns false.

Calling sem_get() fixes the bug

Test script:
---------------
$processes = 300;
$shmem     = shm_attach(ftok(__FILE__, 'f'), 100000);
// If uncomment next line shm_put_var works correctly
// $sem   = sem_get(ftok(__FILE__, 'a'));
for ($i = 1; $i <= $processes; $i++) {
    if (pcntl_fork() === 0) {
        usleep(100000);
        $pid    = getmypid();
        $put_ok = shm_put_var($shmem, $pid, $i);
        if ($put_ok && !shm_has_var($shmem, $pid)) {
            print "shm_put_var() bug\n";
        }
        exit(0);
    }
}
while (pcntl_wait($status) !== -1){}

shm_remove($shmem);
shm_detach($shmem);


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



Thread (3 messages)

« previous php.bugs (#211818) next »