#31854 [NEW]: Segfault if set memory_limit and other goodies

From: Date: Sat, 05 Feb 2005 19:31:27 +0000
Subject: #31854 [NEW]: Segfault if set memory_limit and other goodies
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73527@lists.php.net to get a copy of this message
From: bertrand at toggg dot com Operating system: FC2 PHP version: 4.3.10 PHP Bug Type: Reproducible crash Bug description: Segfault if set memory_limit and other goodies Description: ------------ This script doubles and again an array of long strings. It accepts 3 parameters: - nb of times to double the array - eventuel memory_limit to set (thus default 8 Mo) - interval of added rows to check memory_get_usage. By 18 loops the 8Mo are exhausted. Depending on the memory setting and the interval to check memory usage, results are somewhat strange. The segmentation fault occurs the same if running from Apache 2.0 Handler It could be related to bug #31624 Reproduce code: --------------- $loop = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1]+0 : 11; $setmem = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2]+0 : ''; // changed if set $chk = isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3]+0 : 100; if ($setmem) { if (ini_set ('memory_limit', $setmem*1048576)) { echo 'Set memory limit to '.$setmem." Mo\n"; } else { echo 'FAILED to set memory limit to '.$setmem." Mo\n"; } } error_reporting(E_ALL); $arr = array (str_repeat('X', 65536)); $mem = 0; while ($loop--) { for ($i = count($arr); $i; $i--) { $arr[] = $arr[0]; if ($i%$chk) continue; if ( ( ($nmem = memory_get_usage()) - $mem) > 1000000) { $mem = $nmem; echo 'Count:'.count($arr)." ($mem bytes)\n"; } } echo $loop.':'.count($arr).'/'.memory_get_usage() . " bytes\n"; // 36640 } echo "\n OK \n"; Expected result: ---------------- 1) no memory_limit set PHP Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes) in /home/bertrand/prog/test/outmem.php on line 19 + break 2) with memory_limit set. If not enough: same as 1) Enough memory: OK Actual result: -------------- 1) no memory_limit set I actually get memory exhausted, but if I lower the memory_get_usage frequence, then no break, must control-C: php outmem.php 18 '' 100 ---> break, get hand back php outmem.php 18 '' 1000 ---> I must abort That means if I check memory_get_usage only each 1000 rows PHP is not coming back, but everything OK if I check each 100 rows ???? PHP Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes) in /home/bertrand/prog/test/outmem.php on line 19 Allowed memory size of 8388608 bytes exhausted (tried to allocate 129 bytes) The second message is coming after a long while, but the PHP is sleeping and I need to break 2) with memory_limit It's as expected but will in both cases (enough mem or not) make a segmentation fault. -- Edit bug report at http://bugs.php.net/?id=31854&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31854&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31854&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31854&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31854&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31854&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31854&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31854&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31854&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31854&r=support Expected behavior: http://bugs.php.net/fix.php?id=31854&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31854&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31854&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31854&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31854&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31854&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31854&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31854&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31854&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31854&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31854&r=mysqlcfg

« previous php.bugs (#73527) next »