php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47328 shmop_open memory leak cause apache crash
Submitted: 2009-02-06 10:26 UTC Modified: 2009-02-08 15:59 UTC
From: hszheng at gmail dot com Assigned:
Status: Not a bug Package: Semaphore related
PHP Version: 5.2.9RC1 OS: win32
Private report: No CVE-ID: None
 [2009-02-06 10:26 UTC] hszheng at gmail dot com
Description:
------------
php version 5.2.6
Build Date 	May 2 2008 18:01:20 
PHP API 	20041225
PHP Extension 	20060613
Zend Extension 	220060519

Apache/2.2.8 (Win32) PHP/5.2.6 
Apache API Version 	20051115 

Request URL http://host/file1.php
Request URL http://host/file2.php and refresh several times.
windows alert that httpd.exe - application error. notice a memory address can not be "read".

In Task manager during the operation, the process httpd.exe memory usage increment quickly, and then crashed.


Reproduce code:
---------------
file1.php
--------------------------
<?php
$int_shm = shmop_open(20000, 'c', 0600, 2048);
shmop_write($int_shm, 'abcd', 0);
shmop_close($int_shm);
echo "OK";
?>

file2.php
--------------------------
<?php
for($i = 0; $i < 10000; $i ++){
    $int_shm = shmop_open(20000, 'a', 0, 0);
    $str_data = trim(shmop_read($int_shm, 0, 100));
    shmop_close($int_shm);
}
echo $str_data;
echo "Done.<br />";
?>

Expected result:
----------------
Warning: shmop_open() [function.shmop-open]: unable to attach or create shared memory segment in F:\home\share_var2.php on line 3

Warning: shmop_read() [function.shmop-read]: no shared memory segment with an id of [0] in F:\home\share_var2.php on line 4

Warning: shmop_close() [function.shmop-close]: no shared memory segment with an id of [0] in F:\home\share_var2.php on line 5


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-08 15:59 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The system only allows so many shm segments, if you saturate the queue 
with the ones from PHP, apache will not be able to create internal 
segments and will abort.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Sep 29 02:03:37 2021 UTC