php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28965 Problem with shmop (cannot delete a segment)
Submitted: 2004-06-30 00:14 UTC Modified: 2006-04-15 21:12 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:2 (50.0%)
From: mauroi at digbang dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.0.0RC3 OS: Windows XP
Private report: No CVE-ID: None
 [2004-06-30 00:14 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-05 01:00 UTC] php-bugs at lists dot php dot net
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".
 [2005-05-12 02:28 UTC] joe at bs0 dot com
Am experiencing the same problem on windows xp with iis and apache2.  Tested in php 4.3.11 and the snapshot in the comment above, no difference.  After calling shmop_delete, memory can still be opened/read on either the same request, or subsequent ones.(am calling shmop_close after delete)
 [2006-04-15 20:59 UTC] piotrprz at gmail dot com
I have the same problem on my windows xp + apache2/php5.1.2
The problem does not occur on Windows 2003 Server build 3790 + iis6/php5.1.2
 [2006-04-15 21:12 UTC] tony2001@php.net
See bug #33011.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 17:01:27 2019 UTC