ID:               33011
 Updated by:       [EMAIL PROTECTED]
 Reported By:      joe at bs0 dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Semaphore related
 Operating System: windows xp
 PHP Version:      5.0.4, 4.3.11
 New Comment:

Bug Micro$oft about it.
If it works on *nix and doesn't work on Windows, than it's definitely
not a PHP problem, because PHP uses the same code in ext/shmop for all
OSes.


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

[2005-05-16 14:35:16] joe at bs0 dot com

you are testing this under windows?

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

[2005-05-16 12:24:09] [EMAIL PROTECTED]

This code outputs for me:

shared memory block marked for deletion.
block closed.
PHP Warning:  shmop_open(): unable to attach or create shared memory
segment in /www/index.php on line 27

Warning: shmop_open(): unable to attach or create shared memory segment
in /www/index.php on line 27
Could not open previously deleted block.

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

[2005-05-15 02:34:02] joe at bs0 dot com

as short as I can make it:

<?php
$toWrite = 'test string';       
$shm_len = strlen($toWrite);

$shm_id = shmop_open(0xff3, "c", 0644, $shm_len);

shmop_write($shm_id, $toWrite, 0);
shmop_close($shm_id);

$shm_id = shmop_open(0xff3, "a", 0, 0); 
$data = shmop_read($shm_id, 0, $shm_len);       
shmop_close($shm_id);

$shm_id = shmop_open(0xff3, "w", 0, 0); 

if (!shmop_delete($shm_id)) {
        echo "Couldn't mark shared memory block for deletion.<br/>";
}
else {
        echo "shared memory block marked for deletion.<br/>";   
}

shmop_close($shm_id);
echo 'block closed.<br/>';

$shm_id = shmop_open(0xff3, "a", 0, 0); 

if($shm_id) {
        $data = shmop_read($shm_id, 0, $shm_len);       
        shmop_close($shm_id);   
        
        echo 'ERROR: Previously deleted block able to be opened.<br/>';
        echo 'Data read : "' . $data . '"';
}
else {
        echo 'Could not open previously deleted block.<br/>';
}
?>

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

[2005-05-15 02:00:15] [EMAIL PROTECTED]

Provide a *short* and *readable* reproduce script without any "actions"
and cases. Just a plain script that runs and shows wrong behaviour.

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

[2005-05-14 21:03:26] joe at bs0 dot com

I realize this, please see the linked to test case, shmop_close is
being called, so shm_nattch is zero. (there are no other processes
using this memory.

There are a couple problems in tsrm_win32.c:

when shmop_delete is called, the block is correctly flagged as needing
to be deleted(descriptor->shm_perm.key = -1), however nothing is done
with this again.  
The call to shmdt should call UnmapViewOfFile and CloseHandle on the
appropriate handles.  
After this, the shm_pair needs to be removed from the global array
held.
The only time the files are unmapped/handles closed is in the
destructor.  This is the wrong place to do it since the destructor is
only called when the sapi module is unloaded.

I've changed the code to take care of these problems, just need to do a
bit more testing.  I'll try to submit a patch later in the day.

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

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
    http://bugs.php.net/33011

-- 
Edit this bug report at http://bugs.php.net/?id=33011&edit=1

Reply via email to