#28965 [Fbk->NoF]: Problem with shmop (cannot delete a segment)
ID: 28965
Updated by: php-bugs@lists.php.net
Reported By: mauroi at digbang dot com
-Status: Feedback
+Status: No Feedback
Bug Type: Unknown/Other Function
Operating System: Windows XP
PHP Version: 5.0.0RC3
New Comment:
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
Previous Comments:
------------------------------------------------------------------------
[2005-02-25 11:19:29] tony2001@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
------------------------------------------------------------------------
[2004-06-30 00:14:40] mauroi at digbang dot com
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 this bug report at http://bugs.php.net/?id=28965&edit=1
Thread (6 messages)