From: agustin dot moyano at gmail dot com Operating system: openSUSE 12.1 (x86_64) PHP version: 5.4.6 Package: Semaphore related Bug Type: Bug Bug description:sem_acquire won't lock on forked environment
Description: ------------ The actual php version is # php --version PHP 5.5.0-dev (cli) (built: Aug 24 2012 16:34:36) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies php was configured with: ./configure --enable-sysvsem --enable-sysvshm --enable-pcntl sem_acquire won't lock when a forked process acquires the semaphore. This behaviour is the same whether sem_get is called in every process or before the first pcntl_fork. It would seem sem_acquire treats forked processes as if they where the same process as the father, even if the got different pid. I also tryed this bug with $ php --version PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch (cli) (built: Jun 13 2012 17:19:58) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies in $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 12.04.1 LTS Release: 12.04 Codename: precise whith exactly the same results. Thanks. Test script: --------------- <?php $pid = pcntl_fork(); if ($pid == -1) { die("could not fork 1"); } else if ($pid) { $pid = pcntl_fork(); if ($pid == -1) { die("could not fork 2"); } else if($pid) { $sem = sem_get('1234'); echo "father try acquire $sem\n"; $time = microtime(); sem_acquire($sem); echo "father acquired in ".($time-microtime())."\n"; } else { $sem = sem_get('1234'); echo "son 2 try acquire $sem\n"; $time=microtime(); sem_acquire($sem); echo "son 2 acquired in ".($time-microtime())."\n"; } } else { $sem = sem_get('1234'); echo "son 1 try acquire $sem\n"; $time=microtime(); sem_acquire($sem); echo "son 1 acquired in ".($time-microtime())."\n"; } ?> Expected result: ---------------- storage-tests:~ # php prueba.php father try acquire Resource id #4 father acquired in -4.6999999999964E-5 son 2 try acquire Resource id #4 son 1 try acquire Resource id #4 Actual result: -------------- storage-tests:~ # php prueba.php father try acquire Resource id #4 father acquired in -4.6999999999964E-5 son 2 try acquire Resource id #4 son 1 try acquire Resource id #4 son 2 acquired in -0.00010599999999999 son 1 acquired in -0.00010499999999997 -- Edit bug report at https://bugs.php.net/bug.php?id=62928&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62928&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62928&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62928&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62928&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62928&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62928&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62928&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62928&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62928&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62928&r=support Expected behavior: https://bugs.php.net/fix.php?id=62928&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62928&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62928&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62928&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62928&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62928&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62928&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62928&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62928&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62928&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62928&r=mysqlcfg