From:             mauroi at digbang dot com
Operating system: Windows XP
PHP version:      5.0.0RC3
PHP Bug Type:     Unknown/Other Function
Bug description:  Problem with shmop (cannot delete a segment)

Description:
------------
First of all, when I call shmop_open with the "n" access mode I always get
an error ("cannot create...").
But also, when I create it with the "c" access mode it works ok. Then (in
another execution) I can read that shared memory segment and it returns
the correct data. If I try to delete the segment the function always
return true, but it does not delete it (on the next request I can read it
anyway).
Looking at the process explorer I can see that the apache process always
get a new "Section" called \BaseNamedObjects\TSRM_SHM_DESCRIPTOR (even if
my PHP script is only reading the segment or deleting the segment, not
creating one).

Thanks in advance.

PS. I get the same error on PHP 4 / Windows XP.

Reproduce code:
---------------
I execute the following script 3 times. First with the READ and DELETE
parts commented. Then with WRITE and DELETE parts commented. And finally
with the WRITE and READ parts commented. 
After that if the segments exists anyway.

<?php
class Foo
{
        function Foo()
        {
                $this->a = '43534553';
                $this->b = 'jeqgfhewfg';
        }
}
$foo = new Foo();
$key = CreateKey('var');

/* WRITE */
$content = serialize($foo);
$shmId = shmop_open($key, "c", 0777, strlen($content));
$written = shmop_write($shmId, $content, 0);
shmop_close($shmId);

/* READ */
$shmId = shmop_open($key, 'a', 0, 0);
$content = shmop_read($shmId, 0, shmop_size($shmId));
shmop_close($shmId);
var_dump($content);

/* DELETE */
$shmId = shmop_open($key, 'w', 0, 0);
$success = shmop_delete($shmId);
shmop_close($shmId);

function CreateKey($key)
{
        $fileName = './' . $key;
        
        if (!file_exists($fileName))
        {
                touch($fileName);
        }
        
        return FTOK($fileName, 'a');
}

function FTOK($pathName, $projId) 
{
        $stat = stat($pathName);
        
        $key = sprintf("%u", 
                (($stat['ino'] & 0xffff) | (($stat['dev'] & 0xff) << 16) | (($projId &
0xff) << 24)));
        
        return $key;
}
?>

Expected result:
----------------
On a fourth request I would expect an error if I execute the READ part

Actual result:
--------------
I get the foo object.

-- 
Edit bug report at http://bugs.php.net/?id=28965&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28965&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28965&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28965&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28965&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28965&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28965&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28965&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28965&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28965&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28965&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28965&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28965&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28965&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28965&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28965&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28965&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28965&r=float

Reply via email to