|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #70753 Default value of sem_get()'s parameter auto_release
Submitted: 2015-10-20 21:59 UTC Modified: -
From: kakkau at grr dot la Assigned:
Status: Open Package: Semaphore related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
35 - 18 = ?
Subscribe to this entry?

 [2015-10-20 21:59 UTC] kakkau at grr dot la
Set the default value for sem_get()'s parameter auto_release to 0 as 1 allows additional acquisition of semaphores when reassigning semaphore resource identifiers although the semaphore was not released yet.

Test script:

class Sem {
  private $key = null;
  private $res = null;
  public function __construct() {
    $this->key = ftok(".",".");
  public function set_res() {
    // 4th parameter auto_released is 1 by default
    $this->res = sem_get($this->key, 1, 0600, 1);
  public function acquire() {
    echo "acquired='".sem_acquire($this->res,true)."'\n";

$s = new Sem();
// NOTE: it allows additional acquisition for simple resource variables too


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Apr 04 11:01:23 2020 UTC