#45013 [NEW]: Semaphore cannot be released under certain circumstances.
From: andre at koethur dot de
Operating system: Linux
PHP version: 4.4.8
PHP Bug Type: Semaphore related
Bug description: Semaphore cannot be released under certain circumstances.
Description:
------------
If I acqure a semaphore in one script, then it is not possible to
release it in another script, even if I set "auto_release" to false.
As I have found out, it has something to do with the "count" attribute
of the "sysvsem_sem"-structure. This value is really only needed by
the
"auto_release"-functionality, so it should be safe to ignore it in
php_sysvsem_semop()-function.
The current cvs-version of sysvsem.c says on line 290:
if (!acquire && sem_ptr->count == 0)
I suggest to change it to:
if (!acquire && sem_ptr->count == 0 && sem_ptr->auto_release)
Reproduce code:
---------------
First script, acquire semaphore:
<?php
$sem_id = sem_get(2405, 1, 0666, false);
if ($sem_id !== false) if (sem_acquire($sem_id)) echo 'Sem acquired!';
?>
Second script, release semaphore:
<?php
$sem_id = sem_get(2405, 1, 0666, false);
if ($sem_id !== false) if (sem_release($sem_id)) echo 'Sem released!';
?>
Expected result:
----------------
The second script should run without errors/warnings and the semaphore
should be released.
Actual result:
--------------
Warning: sem_release() [function.sem-release]: SysV semaphore 2 (key
0x965) is not currently acquired
--
Edit bug report at http://bugs.php.net/?id=45013&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45013&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45013&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45013&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45013&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=45013&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45013&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45013&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45013&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45013&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45013&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=45013&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=45013&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45013&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45013&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45013&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45013&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45013&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45013&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45013&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45013&r=mysqlcfg
Thread (4 messages)
- andre at koethur dot de