php.net |  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: 2020-11-16 16:51 UTC
From: kakkau at grr dot la Assigned:
Status: Suspended Package: Semaphore related
PHP Version: Irrelevant OS:
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kakkau at grr dot la
New email:
PHP Version: OS:

 

 [2015-10-20 21:59 UTC] kakkau at grr dot la
Description:
------------
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:
---------------
<?php

class Sem {
  private $key = null;
  private $res = null;
  public function __construct() {
    $this->key = ftok(".",".");
    $this->set_res();
    $this->acquire();
  }
  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();
$s->set_res();
$s->acquire();
// NOTE: it allows additional acquisition for simple resource variables too

?>

Expected result:
----------------
acquired='1'
acquired=''

Actual result:
--------------
acquired='1'
acquired='1'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-16 16:51 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2020-11-16 16:51 UTC] cmb@php.net
Changing a default value of a function can cause a serious BC
break.  As such this request needs to be discussed on the
internals mailing list.  Please forward your request.  For the
time being, I'm suspending this ticket.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC