#39987 [NEW]: loss of resources

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #39987 [NEW]: loss of resources

    From: wojtekm86 at konto dot pl
    Operating system: Linux
    PHP version: 5.2.0
    PHP Bug Type: Semaphore related
    Bug description: loss of resources

    Description:
    ------------
    It's impossible to correct remove semaphores with sem_remove function when
    I use them to provide execution of concurrent processes.
    When the last process releases the semaphore I should be able to remove
    it. But I don't know if another process haven't acquired the semaphore.
    For safety reasons I don't remove released semaphores from system.
    Now, If I get 128 semaphores and I execute sem_get one more time I will
    get warning.
    So, I can't remove semaphores (because I don't know if another process is
    using it) and I can't get next semaphore.

    Reproduce code:
    ---------------
    $id = sem_get(SOME_ID);
    sem_acquire($id);

    HERE IS CRITICAL REGION

    sem_release($id);

    Expected result:
    ----------------
    Expected result (and correct, I think) is removal of unused semaphore in
    sem_release function if another process didn't acquire it and isn't
    waiting for doing this.

    Release and Removal of semaphore should be one chain of instructions
    without possibility of separation (e.g. by interruption).

    Actual result:
    --------------
    System reaches the maximum number of semaphores and warning is reported.
    The warning is: Warning: sem_get() [function.sem-get]: failed for key
    0x5202e59f: No space
    left on device in /home/cicik/ftp/php-art/klasy/semafor.php on line 8


    --
    Edit bug report at [url]http://bugs.php.net/?id=39987&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39987&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39987&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39987&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39987&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=39987&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=39987&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39987&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=39987&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=39987&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=39987&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=39987&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=39987&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=39987&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39987&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=39987&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=39987&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39987&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=39987&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39987&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39987&r=mysqlcfg[/url]
    wojtekm86 at konto dot pl Guest

  2. Similar Questions and Discussions

    1. FLV TO 3 GP AUDIO LOSS
      Please help me with this one: Using RHEL4 running fms2. The .FLVs created by FMS play well (include audio as well as video), however, when they are...
    2. Hair Loss !!
      Hello Peeps. I am tring to install FLEX on my test server and I am totally lost. I am running IIS6 server with CF7 (Multisite) on JRun4. I...
    3. .w3d animation loss
      Hello, I am trying to export a model from 3D studio max in .w3d format. The model contains an animation developed in Studio Max. When I try to...
    4. Loss of Focus
      Hi, I'm using flash 2004 MX Pro. I want to create a textfield that when it loses focus, ie, the user navigates away, it triggers an event. how...
    5. I'm at a loss
      Joel, Don't feed the trollism's... Paul ///////////////////// "Joel M. Eichen D.D.S." <joeleichen@yahoo.com> wrote in message...
  3. #2

    Default #39987 [Opn->Fbk]: loss of resources

    ID: 39987
    Updated by: [email]tony2001@php.net[/email]
    Reported By: wojtekm86 at konto dot pl
    -Status: Open
    +Status: Feedback
    Bug Type: Semaphore related
    Operating System: Linux
    PHP Version: 5.2.0
    New Comment:

    Cannot reproduce.
    sem_release() DOES remove the semaphor if no other process uses it.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-29 17:01:23] wojtekm86 at konto dot pl

    Description:
    ------------
    It's impossible to correct remove semaphores with sem_remove function
    when I use them to provide execution of concurrent processes.
    When the last process releases the semaphore I should be able to remove
    it. But I don't know if another process haven't acquired the semaphore.
    For safety reasons I don't remove released semaphores from system.
    Now, If I get 128 semaphores and I execute sem_get one more time I will
    get warning.
    So, I can't remove semaphores (because I don't know if another process
    is using it) and I can't get next semaphore.

    Reproduce code:
    ---------------
    $id = sem_get(SOME_ID);
    sem_acquire($id);

    HERE IS CRITICAL REGION

    sem_release($id);

    Expected result:
    ----------------
    Expected result (and correct, I think) is removal of unused semaphore
    in sem_release function if another process didn't acquire it and isn't
    waiting for doing this.

    Release and Removal of semaphore should be one chain of instructions
    without possibility of separation (e.g. by interruption).

    Actual result:
    --------------
    System reaches the maximum number of semaphores and warning is
    reported.
    The warning is: Warning: sem_get() [function.sem-get]: failed for key
    0x5202e59f: No space
    left on device in /home/cicik/ftp/php-art/klasy/semafor.php on line 8



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39987&edit=1[/url]
    tony2001@php.net Guest

  4. #3

    Default #39987 [Fbk->Opn]: loss of resources

    ID: 39987
    User updated by: wojtekm86 at konto dot pl
    Reported By: wojtekm86 at konto dot pl
    -Status: Feedback
    +Status: Open
    Bug Type: Semaphore related
    Operating System: Linux
    PHP Version: 5.2.0
    New Comment:

    I think it doesn't.
    In my script I have class Semaphore.
    There are methods like acquire() and release().
    After each sem_acquire instruction I wrote:

    echo('I\'ve acquired semaphore key: ' . $this->key . '<br>');

    After each sem_release instruction I wrote:

    echo('I\'ve released semaphore key: ' . $this->key . '<br>');

    I have executed script only once.
    The result I saw is:

    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159747
    I've released semaphore key: 1376159747
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159748
    I've released semaphore key: 1376159748
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159749
    I've released semaphore key: 1376159749

    As you can see each semaphore is released.
    But when I run command ipcs -s on my server I get:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x520687e6 131075 www_php-a 600 3
    0x520687f9 163844 www_php-a 600 3
    0x520687fa 196613 www_php-a 600 3
    0x520687fc 229382 www_php-a 600 3
    0x520687e9 262151 www_php-a 600 3
    0x520687fd 294920 www_php-a 600 3
    0x520687fe 327689 www_php-a 600 3
    0x520687ff 360458 www_php-a 600 3
    0x52068800 393227 www_php-a 600 3
    0x52068801 425996 www_php-a 600 3
    0x52068802 458765 www_php-a 600 3
    0x52068803 491534 www_php-a 600 3
    0x52068804 524303 www_php-a 600 3
    0x52068805 557072 www_php-a 600 3

    You can see that there are not removed semaphores.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-29 17:14:48] [email]tony2001@php.net[/email]

    Cannot reproduce.
    sem_release() DOES remove the semaphor if no other process uses it.

    ------------------------------------------------------------------------

    [2006-12-29 17:01:23] wojtekm86 at konto dot pl

    Description:
    ------------
    It's impossible to correct remove semaphores with sem_remove function
    when I use them to provide execution of concurrent processes.
    When the last process releases the semaphore I should be able to remove
    it. But I don't know if another process haven't acquired the semaphore.
    For safety reasons I don't remove released semaphores from system.
    Now, If I get 128 semaphores and I execute sem_get one more time I will
    get warning.
    So, I can't remove semaphores (because I don't know if another process
    is using it) and I can't get next semaphore.

    Reproduce code:
    ---------------
    $id = sem_get(SOME_ID);
    sem_acquire($id);

    HERE IS CRITICAL REGION

    sem_release($id);

    Expected result:
    ----------------
    Expected result (and correct, I think) is removal of unused semaphore
    in sem_release function if another process didn't acquire it and isn't
    waiting for doing this.

    Release and Removal of semaphore should be one chain of instructions
    without possibility of separation (e.g. by interruption).

    Actual result:
    --------------
    System reaches the maximum number of semaphores and warning is
    reported.
    The warning is: Warning: sem_get() [function.sem-get]: failed for key
    0x5202e59f: No space
    left on device in /home/cicik/ftp/php-art/klasy/semafor.php on line 8



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39987&edit=1[/url]
    wojtekm86 at konto dot pl Guest

  5. #4

    Default #39987 [Opn]: loss of resources

    ID: 39987
    User updated by: wojtekm86 at konto dot pl
    Reported By: wojtekm86 at konto dot pl
    Status: Open
    Bug Type: Semaphore related
    Operating System: Linux
    PHP Version: 5.2.0
    New Comment:

    Next code.

    I have a test script with code as follows:

    <?php
    $id = sem_get(10);
    sem_acquire($id);
    for($ind = 0; $ind < 10000; $ind++) { }
    sem_release($id);
    ?>

    I run it only once.

    The result I get after execute command ipcs -s on the server:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x0000000a 131075 www_php-a 666 3

    It seems that there is a problem with semaphores' removal after
    release.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-29 17:33:32] wojtekm86 at konto dot pl

    I think it doesn't.
    In my script I have class Semaphore.
    There are methods like acquire() and release().
    After each sem_acquire instruction I wrote:

    echo('I\'ve acquired semaphore key: ' . $this->key . '<br>');

    After each sem_release instruction I wrote:

    echo('I\'ve released semaphore key: ' . $this->key . '<br>');

    I have executed script only once.
    The result I saw is:

    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159747
    I've released semaphore key: 1376159747
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159748
    I've released semaphore key: 1376159748
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159749
    I've released semaphore key: 1376159749

    As you can see each semaphore is released.
    But when I run command ipcs -s on my server I get:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x520687e6 131075 www_php-a 600 3
    0x520687f9 163844 www_php-a 600 3
    0x520687fa 196613 www_php-a 600 3
    0x520687fc 229382 www_php-a 600 3
    0x520687e9 262151 www_php-a 600 3
    0x520687fd 294920 www_php-a 600 3
    0x520687fe 327689 www_php-a 600 3
    0x520687ff 360458 www_php-a 600 3
    0x52068800 393227 www_php-a 600 3
    0x52068801 425996 www_php-a 600 3
    0x52068802 458765 www_php-a 600 3
    0x52068803 491534 www_php-a 600 3
    0x52068804 524303 www_php-a 600 3
    0x52068805 557072 www_php-a 600 3

    You can see that there are not removed semaphores.

    ------------------------------------------------------------------------

    [2006-12-29 17:14:48] [email]tony2001@php.net[/email]

    Cannot reproduce.
    sem_release() DOES remove the semaphor if no other process uses it.

    ------------------------------------------------------------------------

    [2006-12-29 17:01:23] wojtekm86 at konto dot pl

    Description:
    ------------
    It's impossible to correct remove semaphores with sem_remove function
    when I use them to provide execution of concurrent processes.
    When the last process releases the semaphore I should be able to remove
    it. But I don't know if another process haven't acquired the semaphore.
    For safety reasons I don't remove released semaphores from system.
    Now, If I get 128 semaphores and I execute sem_get one more time I will
    get warning.
    So, I can't remove semaphores (because I don't know if another process
    is using it) and I can't get next semaphore.

    Reproduce code:
    ---------------
    $id = sem_get(SOME_ID);
    sem_acquire($id);

    HERE IS CRITICAL REGION

    sem_release($id);

    Expected result:
    ----------------
    Expected result (and correct, I think) is removal of unused semaphore
    in sem_release function if another process didn't acquire it and isn't
    waiting for doing this.

    Release and Removal of semaphore should be one chain of instructions
    without possibility of separation (e.g. by interruption).

    Actual result:
    --------------
    System reaches the maximum number of semaphores and warning is
    reported.
    The warning is: Warning: sem_get() [function.sem-get]: failed for key
    0x5202e59f: No space
    left on device in /home/cicik/ftp/php-art/klasy/semafor.php on line 8



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39987&edit=1[/url]
    wojtekm86 at konto dot pl Guest

  6. #5

    Default #39987 [Opn]: loss of resources

    ID: 39987
    User updated by: wojtekm86 at konto dot pl
    Reported By: wojtekm86 at konto dot pl
    Status: Open
    Bug Type: Semaphore related
    Operating System: Linux
    PHP Version: 5.2.0
    New Comment:

    I think that there is also a problem with parameter max_acquire because
    value in column nsems always equals 3


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-29 17:45:15] wojtekm86 at konto dot pl

    Next code.

    I have a test script with code as follows:

    <?php
    $id = sem_get(10);
    sem_acquire($id);
    for($ind = 0; $ind < 10000; $ind++) { }
    sem_release($id);
    ?>

    I run it only once.

    The result I get after execute command ipcs -s on the server:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x0000000a 131075 www_php-a 666 3

    It seems that there is a problem with semaphores' removal after
    release.

    ------------------------------------------------------------------------

    [2006-12-29 17:33:32] wojtekm86 at konto dot pl

    I think it doesn't.
    In my script I have class Semaphore.
    There are methods like acquire() and release().
    After each sem_acquire instruction I wrote:

    echo('I\'ve acquired semaphore key: ' . $this->key . '<br>');

    After each sem_release instruction I wrote:

    echo('I\'ve released semaphore key: ' . $this->key . '<br>');

    I have executed script only once.
    The result I saw is:

    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159747
    I've released semaphore key: 1376159747
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159748
    I've released semaphore key: 1376159748
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159749
    I've released semaphore key: 1376159749

    As you can see each semaphore is released.
    But when I run command ipcs -s on my server I get:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x520687e6 131075 www_php-a 600 3
    0x520687f9 163844 www_php-a 600 3
    0x520687fa 196613 www_php-a 600 3
    0x520687fc 229382 www_php-a 600 3
    0x520687e9 262151 www_php-a 600 3
    0x520687fd 294920 www_php-a 600 3
    0x520687fe 327689 www_php-a 600 3
    0x520687ff 360458 www_php-a 600 3
    0x52068800 393227 www_php-a 600 3
    0x52068801 425996 www_php-a 600 3
    0x52068802 458765 www_php-a 600 3
    0x52068803 491534 www_php-a 600 3
    0x52068804 524303 www_php-a 600 3
    0x52068805 557072 www_php-a 600 3

    You can see that there are not removed semaphores.

    ------------------------------------------------------------------------

    [2006-12-29 17:14:48] [email]tony2001@php.net[/email]

    Cannot reproduce.
    sem_release() DOES remove the semaphor if no other process uses it.

    ------------------------------------------------------------------------

    [2006-12-29 17:01:23] wojtekm86 at konto dot pl

    Description:
    ------------
    It's impossible to correct remove semaphores with sem_remove function
    when I use them to provide execution of concurrent processes.
    When the last process releases the semaphore I should be able to remove
    it. But I don't know if another process haven't acquired the semaphore.
    For safety reasons I don't remove released semaphores from system.
    Now, If I get 128 semaphores and I execute sem_get one more time I will
    get warning.
    So, I can't remove semaphores (because I don't know if another process
    is using it) and I can't get next semaphore.

    Reproduce code:
    ---------------
    $id = sem_get(SOME_ID);
    sem_acquire($id);

    HERE IS CRITICAL REGION

    sem_release($id);

    Expected result:
    ----------------
    Expected result (and correct, I think) is removal of unused semaphore
    in sem_release function if another process didn't acquire it and isn't
    waiting for doing this.

    Release and Removal of semaphore should be one chain of instructions
    without possibility of separation (e.g. by interruption).

    Actual result:
    --------------
    System reaches the maximum number of semaphores and warning is
    reported.
    The warning is: Warning: sem_get() [function.sem-get]: failed for key
    0x5202e59f: No space
    left on device in /home/cicik/ftp/php-art/klasy/semafor.php on line 8



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39987&edit=1[/url]
    wojtekm86 at konto dot pl Guest

  7. #6

    Default #39987 [Opn->Bgs]: loss of resources

    ID: 39987
    Updated by: [email]iliaa@php.net[/email]
    Reported By: wojtekm86 at konto dot pl
    -Status: Open
    +Status: Bogus
    Bug Type: Semaphore related
    Operating System: Linux
    PHP Version: 5.2.0
    New Comment:

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    if you want to remove the semaphore you need to call the
    sem_remove() function. Closing the semaphore won't remove it
    no more so then closing a file will remove it from disk.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-30 10:54:20] wojtekm86 at konto dot pl

    I think that there is also a problem with parameter max_acquire because
    value in column nsems always equals 3

    ------------------------------------------------------------------------

    [2006-12-29 17:45:15] wojtekm86 at konto dot pl

    Next code.

    I have a test script with code as follows:

    <?php
    $id = sem_get(10);
    sem_acquire($id);
    for($ind = 0; $ind < 10000; $ind++) { }
    sem_release($id);
    ?>

    I run it only once.

    The result I get after execute command ipcs -s on the server:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x0000000a 131075 www_php-a 666 3

    It seems that there is a problem with semaphores' removal after
    release.

    ------------------------------------------------------------------------

    [2006-12-29 17:33:32] wojtekm86 at konto dot pl

    I think it doesn't.
    In my script I have class Semaphore.
    There are methods like acquire() and release().
    After each sem_acquire instruction I wrote:

    echo('I\'ve acquired semaphore key: ' . $this->key . '<br>');

    After each sem_release instruction I wrote:

    echo('I\'ve released semaphore key: ' . $this->key . '<br>');

    I have executed script only once.
    The result I saw is:

    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159747
    I've released semaphore key: 1376159747
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159748
    I've released semaphore key: 1376159748
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159749
    I've released semaphore key: 1376159749

    As you can see each semaphore is released.
    But when I run command ipcs -s on my server I get:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x520687e6 131075 www_php-a 600 3
    0x520687f9 163844 www_php-a 600 3
    0x520687fa 196613 www_php-a 600 3
    0x520687fc 229382 www_php-a 600 3
    0x520687e9 262151 www_php-a 600 3
    0x520687fd 294920 www_php-a 600 3
    0x520687fe 327689 www_php-a 600 3
    0x520687ff 360458 www_php-a 600 3
    0x52068800 393227 www_php-a 600 3
    0x52068801 425996 www_php-a 600 3
    0x52068802 458765 www_php-a 600 3
    0x52068803 491534 www_php-a 600 3
    0x52068804 524303 www_php-a 600 3
    0x52068805 557072 www_php-a 600 3

    You can see that there are not removed semaphores.

    ------------------------------------------------------------------------

    [2006-12-29 17:14:48] [email]tony2001@php.net[/email]

    Cannot reproduce.
    sem_release() DOES remove the semaphor if no other process uses it.

    ------------------------------------------------------------------------

    [2006-12-29 17:01:23] wojtekm86 at konto dot pl

    Description:
    ------------
    It's impossible to correct remove semaphores with sem_remove function
    when I use them to provide execution of concurrent processes.
    When the last process releases the semaphore I should be able to remove
    it. But I don't know if another process haven't acquired the semaphore.
    For safety reasons I don't remove released semaphores from system.
    Now, If I get 128 semaphores and I execute sem_get one more time I will
    get warning.
    So, I can't remove semaphores (because I don't know if another process
    is using it) and I can't get next semaphore.

    Reproduce code:
    ---------------
    $id = sem_get(SOME_ID);
    sem_acquire($id);

    HERE IS CRITICAL REGION

    sem_release($id);

    Expected result:
    ----------------
    Expected result (and correct, I think) is removal of unused semaphore
    in sem_release function if another process didn't acquire it and isn't
    waiting for doing this.

    Release and Removal of semaphore should be one chain of instructions
    without possibility of separation (e.g. by interruption).

    Actual result:
    --------------
    System reaches the maximum number of semaphores and warning is
    reported.
    The warning is: Warning: sem_get() [function.sem-get]: failed for key
    0x5202e59f: No space
    left on device in /home/cicik/ftp/php-art/klasy/semafor.php on line 8



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39987&edit=1[/url]
    iliaa@php.net Guest

  8. #7

    Default #39987 [Bgs]: loss of resources

    ID: 39987
    User updated by: wojtekm86 at konto dot pl
    Reported By: wojtekm86 at konto dot pl
    Status: Bogus
    Bug Type: Semaphore related
    Operating System: Linux
    PHP Version: 5.2.0
    New Comment:

    I think you don't understand me.
    I know that sem_release doesn't remove the semaphore but I think it
    should because it's the one and only way to do it correct, of course if
    current process, which releases a semaphore, is the last one which
    acquired it.

    Please, read one more time bug's description.
    I think you didn't understand my intention.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-30 23:19:34] [email]iliaa@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    if you want to remove the semaphore you need to call the
    sem_remove() function. Closing the semaphore won't remove it
    no more so then closing a file will remove it from disk.

    ------------------------------------------------------------------------

    [2006-12-30 10:54:20] wojtekm86 at konto dot pl

    I think that there is also a problem with parameter max_acquire because
    value in column nsems always equals 3

    ------------------------------------------------------------------------

    [2006-12-29 17:45:15] wojtekm86 at konto dot pl

    Next code.

    I have a test script with code as follows:

    <?php
    $id = sem_get(10);
    sem_acquire($id);
    for($ind = 0; $ind < 10000; $ind++) { }
    sem_release($id);
    ?>

    I run it only once.

    The result I get after execute command ipcs -s on the server:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x0000000a 131075 www_php-a 666 3

    It seems that there is a problem with semaphores' removal after
    release.

    ------------------------------------------------------------------------

    [2006-12-29 17:33:32] wojtekm86 at konto dot pl

    I think it doesn't.
    In my script I have class Semaphore.
    There are methods like acquire() and release().
    After each sem_acquire instruction I wrote:

    echo('I\'ve acquired semaphore key: ' . $this->key . '<br>');

    After each sem_release instruction I wrote:

    echo('I\'ve released semaphore key: ' . $this->key . '<br>');

    I have executed script only once.
    The result I saw is:

    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159747
    I've released semaphore key: 1376159747
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159748
    I've released semaphore key: 1376159748
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159749
    I've released semaphore key: 1376159749

    As you can see each semaphore is released.
    But when I run command ipcs -s on my server I get:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x520687e6 131075 www_php-a 600 3
    0x520687f9 163844 www_php-a 600 3
    0x520687fa 196613 www_php-a 600 3
    0x520687fc 229382 www_php-a 600 3
    0x520687e9 262151 www_php-a 600 3
    0x520687fd 294920 www_php-a 600 3
    0x520687fe 327689 www_php-a 600 3
    0x520687ff 360458 www_php-a 600 3
    0x52068800 393227 www_php-a 600 3
    0x52068801 425996 www_php-a 600 3
    0x52068802 458765 www_php-a 600 3
    0x52068803 491534 www_php-a 600 3
    0x52068804 524303 www_php-a 600 3
    0x52068805 557072 www_php-a 600 3

    You can see that there are not removed semaphores.

    ------------------------------------------------------------------------

    [2006-12-29 17:14:48] [email]tony2001@php.net[/email]

    Cannot reproduce.
    sem_release() DOES remove the semaphor if no other process uses it.

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39987[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39987&edit=1[/url]
    wojtekm86 at konto dot pl Guest

  9. #8

    Default #39987 [Bgs->Opn]: loss of resources

    ID: 39987
    User updated by: wojtekm86 at konto dot pl
    Reported By: wojtekm86 at konto dot pl
    -Status: Bogus
    +Status: Open
    Bug Type: Semaphore related
    Operating System: Linux
    PHP Version: 5.2.0
    New Comment:

    I'm changing the status to Open


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-31 08:24:09] wojtekm86 at konto dot pl

    I think you don't understand me.
    I know that sem_release doesn't remove the semaphore but I think it
    should because it's the one and only way to do it correct, of course if
    current process, which releases a semaphore, is the last one which
    acquired it.

    Please, read one more time bug's description.
    I think you didn't understand my intention.

    ------------------------------------------------------------------------

    [2006-12-30 23:19:34] [email]iliaa@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    if you want to remove the semaphore you need to call the
    sem_remove() function. Closing the semaphore won't remove it
    no more so then closing a file will remove it from disk.

    ------------------------------------------------------------------------

    [2006-12-30 10:54:20] wojtekm86 at konto dot pl

    I think that there is also a problem with parameter max_acquire because
    value in column nsems always equals 3

    ------------------------------------------------------------------------

    [2006-12-29 17:45:15] wojtekm86 at konto dot pl

    Next code.

    I have a test script with code as follows:

    <?php
    $id = sem_get(10);
    sem_acquire($id);
    for($ind = 0; $ind < 10000; $ind++) { }
    sem_release($id);
    ?>

    I run it only once.

    The result I get after execute command ipcs -s on the server:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x0000000a 131075 www_php-a 666 3

    It seems that there is a problem with semaphores' removal after
    release.

    ------------------------------------------------------------------------

    [2006-12-29 17:33:32] wojtekm86 at konto dot pl

    I think it doesn't.
    In my script I have class Semaphore.
    There are methods like acquire() and release().
    After each sem_acquire instruction I wrote:

    echo('I\'ve acquired semaphore key: ' . $this->key . '<br>');

    After each sem_release instruction I wrote:

    echo('I\'ve released semaphore key: ' . $this->key . '<br>');

    I have executed script only once.
    The result I saw is:

    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159747
    I've released semaphore key: 1376159747
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159748
    I've released semaphore key: 1376159748
    I've acquired semaphore key: 1376159737
    I've released semaphore key: 1376159737
    I've acquired semaphore key: 1376159749
    I've released semaphore key: 1376159749

    As you can see each semaphore is released.
    But when I run command ipcs -s on my server I get:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x520687e6 131075 www_php-a 600 3
    0x520687f9 163844 www_php-a 600 3
    0x520687fa 196613 www_php-a 600 3
    0x520687fc 229382 www_php-a 600 3
    0x520687e9 262151 www_php-a 600 3
    0x520687fd 294920 www_php-a 600 3
    0x520687fe 327689 www_php-a 600 3
    0x520687ff 360458 www_php-a 600 3
    0x52068800 393227 www_php-a 600 3
    0x52068801 425996 www_php-a 600 3
    0x52068802 458765 www_php-a 600 3
    0x52068803 491534 www_php-a 600 3
    0x52068804 524303 www_php-a 600 3
    0x52068805 557072 www_php-a 600 3

    You can see that there are not removed semaphores.

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39987[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39987&edit=1[/url]
    wojtekm86 at konto dot pl Guest

  10. #9

    Default #39987 [Opn]: loss of resources

    ID: 39987
    User updated by: wojtekm86 at konto dot pl
    Reported By: wojtekm86 at konto dot pl
    Status: Open
    Bug Type: Semaphore related
    Operating System: Linux
    PHP Version: 5.2.0
    New Comment:

    I will try to tell about my sugestion.

    I assume that I have a function my_sem_remove($sem_id):

    function my_sem_remove($id) {
    if(Semaphore $id isn't acquired and its FIFO is empty)
    sem_remove($id);
    }
    None of instructions in this function can be interrupted.
    So, now the problem is simple to resolve:

    $id = sem_get(ID);
    sem_acquire($id);

    CRITICAL REGION

    sem_release($id);
    my_sem_remove($id);

    But now, two instructions: sem_release and my_sem_remove are not
    needed. It's simple to replace them by one function my_sem_release:

    function my_sem_release($id) {
    sem_release($id);
    my_sem_remove($id);
    }

    For reasons which about I will write later those instructions can't be
    interrupted.

    So, my example look like this:

    $id = sem_get(ID);
    sem_acquire($id);

    CRITICAL REGION

    my_sem_release($id);

    But let's imagine two concurrent processes executing code above:

    PROC1: $id = sem_get(ID);
    <--- interrupt
    PROC2: $id = sem_get(ID);
    sem_acquire($id);
    CRITICAL REGION
    my_sem_release($id);
    <--- interrupt
    PROC1: sem_acquire($id); <--- Uuups!! Error: semaphore doesn't exists,
    PROC2 has removed it.

    My solution:
    Instructions sem_get and sem_acquire can't be interrupted.
    So, I assume that there is a function my_sem_acquire:

    function my_sem_acquire($key, $max_acquire = 1, $perm = 0666,
    $auto_release = true) {

    $id = sem_get($key, $max_acquire, $perm, $auto_release);
    sem_acquire();
    return $id;
    }

    None of instructions in function above can be interrupted.

    And finally correct example:

    $id = my_sem_acquire(SEMKEY);

    CRITICAL REGION

    my_sem_release($id);

    It's the best solutions without danger of operating on not existing
    semaphores. Also, unused semaphores are automaticcally removed. The
    problem is, that functions my_sem_acquire and my_sem_release can't be
    witten in PHP so it must be done in C inside source of PHP.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-31 08:26:11] wojtekm86 at konto dot pl

    I'm changing the status to Open

    ------------------------------------------------------------------------

    [2006-12-31 08:24:09] wojtekm86 at konto dot pl

    I think you don't understand me.
    I know that sem_release doesn't remove the semaphore but I think it
    should because it's the one and only way to do it correct, of course if
    current process, which releases a semaphore, is the last one which
    acquired it.

    Please, read one more time bug's description.
    I think you didn't understand my intention.

    ------------------------------------------------------------------------

    [2006-12-30 23:19:34] [email]iliaa@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    if you want to remove the semaphore you need to call the
    sem_remove() function. Closing the semaphore won't remove it
    no more so then closing a file will remove it from disk.

    ------------------------------------------------------------------------

    [2006-12-30 10:54:20] wojtekm86 at konto dot pl

    I think that there is also a problem with parameter max_acquire because
    value in column nsems always equals 3

    ------------------------------------------------------------------------

    [2006-12-29 17:45:15] wojtekm86 at konto dot pl

    Next code.

    I have a test script with code as follows:

    <?php
    $id = sem_get(10);
    sem_acquire($id);
    for($ind = 0; $ind < 10000; $ind++) { }
    sem_release($id);
    ?>

    I run it only once.

    The result I get after execute command ipcs -s on the server:

    ------ Semaphore Arrays --------
    key semid owner perms nsems
    0x0000000a 131075 www_php-a 666 3

    It seems that there is a problem with semaphores' removal after
    release.

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39987[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39987&edit=1[/url]
    wojtekm86 at konto dot pl Guest

  11. #10

    Default #39987 [Opn->Bgs]: loss of resources

    ID: 39987
    Updated by: [email]iliaa@php.net[/email]
    Reported By: wojtekm86 at konto dot pl
    -Status: Open
    +Status: Bogus
    Bug Type: Semaphore related
    Operating System: Linux
    PHP Version: 5.2.0
    New Comment:

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    If you want, please make a feature request. However, the
    current behavior is absolutely correct.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-31 09:13:49] wojtekm86 at konto dot pl

    I will try to tell about my sugestion.

    I assume that I have a function my_sem_remove($sem_id):

    function my_sem_remove($id) {
    if(Semaphore $id isn't acquired and its FIFO is empty)
    sem_remove($id);
    }
    None of instructions in this function can be interrupted.
    So, now the problem is simple to resolve:

    $id = sem_get(ID);
    sem_acquire($id);

    CRITICAL REGION

    sem_release($id);
    my_sem_remove($id);

    But now, two instructions: sem_release and my_sem_remove are not
    needed. It's simple to replace them by one function my_sem_release:

    function my_sem_release($id) {
    sem_release($id);
    my_sem_remove($id);
    }

    For reasons which about I will write later those instructions can't be
    interrupted.

    So, my example look like this:

    $id = sem_get(ID);
    sem_acquire($id);

    CRITICAL REGION

    my_sem_release($id);

    But let's imagine two concurrent processes executing code above:

    PROC1: $id = sem_get(ID);
    <--- interrupt
    PROC2: $id = sem_get(ID);
    sem_acquire($id);
    CRITICAL REGION
    my_sem_release($id);
    <--- interrupt
    PROC1: sem_acquire($id); <--- Uuups!! Error: semaphore doesn't exists,
    PROC2 has removed it.

    My solution:
    Instructions sem_get and sem_acquire can't be interrupted.
    So, I assume that there is a function my_sem_acquire:

    function my_sem_acquire($key, $max_acquire = 1, $perm = 0666,
    $auto_release = true) {

    $id = sem_get($key, $max_acquire, $perm, $auto_release);
    sem_acquire();
    return $id;
    }

    None of instructions in function above can be interrupted.

    And finally correct example:

    $id = my_sem_acquire(SEMKEY);

    CRITICAL REGION

    my_sem_release($id);

    It's the best solutions without danger of operating on not existing
    semaphores. Also, unused semaphores are automaticcally removed. The
    problem is, that functions my_sem_acquire and my_sem_release can't be
    witten in PHP so it must be done in C inside source of PHP.

    ------------------------------------------------------------------------

    [2006-12-31 08:26:11] wojtekm86 at konto dot pl

    I'm changing the status to Open

    ------------------------------------------------------------------------

    [2006-12-31 08:24:09] wojtekm86 at konto dot pl

    I think you don't understand me.
    I know that sem_release doesn't remove the semaphore but I think it
    should because it's the one and only way to do it correct, of course if
    current process, which releases a semaphore, is the last one which
    acquired it.

    Please, read one more time bug's description.
    I think you didn't understand my intention.

    ------------------------------------------------------------------------

    [2006-12-30 23:19:34] [email]iliaa@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    if you want to remove the semaphore you need to call the
    sem_remove() function. Closing the semaphore won't remove it
    no more so then closing a file will remove it from disk.

    ------------------------------------------------------------------------

    [2006-12-30 10:54:20] wojtekm86 at konto dot pl

    I think that there is also a problem with parameter max_acquire because
    value in column nsems always equals 3

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39987[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39987&edit=1[/url]
    iliaa@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139