|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75415 shm_put_var() parallel bug.
Submitted: 2017-10-22 10:04 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: abc905 at mail dot ru Assigned:
Status: Open Package: Semaphore related
PHP Version: 7.1.10 OS: Linux Debian 4.9.0-4-amd64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: abc905 at mail dot ru
New email:
PHP Version: OS:


 [2017-10-22 10:04 UTC] abc905 at mail dot ru
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) {
        $pid    = getmypid();
        $put_ok = shm_put_var($shmem, $pid, $i);
        if ($put_ok && !shm_has_var($shmem, $pid)) {
            print "shm_put_var() bug\n";
while (pcntl_wait($status) !== -1){}



Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 21 16:03:36 2021 UTC