php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13596 php crash on second accessing of allocated memory
Submitted: 2001-10-08 07:33 UTC Modified: 2002-01-16 05:45 UTC
From: ozoon at vnet dot ee Assigned:
Status: Closed Package: Semaphore related
PHP Version: 4.0.6 OS: redhat 7.1
Private report: No CVE-ID: None
 [2001-10-08 07:33 UTC] ozoon at vnet dot ee
Hi.
Its seems to be impossible to use shmop_write if you are opening memory segment secong time.
example code (produces crash):

$mid = 0xffe;

$shm_id = shmop_open($mid, "c", 0644, 100);
if(!$shm_id) {
        echo "Couldn't create shared memory segment\n";
}
$shm_bytes_written = shmop_write($shm_id, "my shared memory block", 0);
if($shm_bytes_written != strlen("my shared memory block")) {
        echo "Couldn't write the entire length of data\n";
}

shmop_close($shm_id);
$shm_id = shmop_open($mid, "a", 0, 0);
$shm_bytes_written = shmop_write($shm_id, "my shared memory block", 0);
if($shm_bytes_written != strlen("my shared memory block")) {
        echo "Couldn't write the entire length of data\n";
}

shmop_close($shm_id);

I did somehting wrong? or i should use other release of PHP?

O.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-08 11:30 UTC] ozoon at vnet dot ee
I got it working, but i had to change C source for it:

in ext/shmop/shmop.c
--------------------------
      if (memchr((*flags)->value.str.val, 'a', (*flags)->value.str.len)) {
                shmflg = SHM_RDONLY;
                shmop->shmflg |= IPC_EXCL;
        }
-------------
changed to:
-------------
        if (memchr((*flags)->value.str.val, 'a', (*flags)->value.str.len)) {
                shmop->shmflg |= IPC_EXCL;
                shmop->shmflg |= SHM_R;
                shmop->shmflg |= SHM_W;
        }
-------------
and it worked....

I hope php 4.0.7 will implement some patch too for it (CVS is still buggy)

Thx.
O.
 [2002-01-14 02:31 UTC] lobbin@php.net
Does this work on 4.1.1?
 [2002-01-16 05:45 UTC] ozoon at vnet dot ee
yes
 [2002-01-16 05:45 UTC] ozoon at vnet dot ee
yes
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Dec 03 11:03:36 2021 UTC