File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / bug55509.phpt
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 01:32:17 2013 UTC (11 years, 8 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17, HEAD
5.4.17

    1: --TEST--
    2: Bug #55509 (segfault on x86_64 using more than 2G memory)
    3: --SKIPIF--
    4: <?php
    5: if (PHP_INT_SIZE == 4) {
    6:   die('skip Not for 32-bits OS');
    7: }
    8: 
    9: $zend_mm_enabled = getenv("USE_ZEND_ALLOC");
   10: if ($zend_mm_enabled === "0") {
   11:     die("skip Zend MM disabled");
   12: }
   13: 
   14: if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
   15: // check the available memory
   16: if (PHP_OS == 'Linux') {
   17:   $lines = file('/proc/meminfo');
   18:   $infos = array();
   19:   foreach ($lines as $line) {
   20:     $tmp = explode(":", $line);
   21:     $index = strtolower($tmp[0]);
   22:     $value = (int)ltrim($tmp[1], " ")*1024;
   23:     $infos[$index] = $value;
   24:   }
   25:   $freeMemory = $infos['memfree']+$infos['buffers']+$infos['cached'];
   26:   if ($freeMemory < 2100*1024*1024) {
   27:     die('skip Not enough memory.');
   28:   }
   29: }
   30: elseif (PHP_OS == 'FreeBSD') {
   31:   $lines = explode("\n",`sysctl -a`);
   32:   $infos = array();
   33:   foreach ($lines as $line) {
   34:     if(!$line){
   35:       continue;
   36:     }
   37:     $tmp = explode(":", $line);
   38:     $index = strtolower($tmp[0]);
   39:     $value = trim($tmp[1], " ");
   40:     $infos[$index] = $value;
   41:   }
   42:   $freeMemory = ($infos['vm.stats.vm.v_inactive_count']*$infos['hw.pagesize'])
   43:                 +($infos['vm.stats.vm.v_cache_count']*$infos['hw.pagesize'])
   44:                 +($infos['vm.stats.vm.v_free_count']*$infos['hw.pagesize']);
   45:   if ($freeMemory < 2100*1024*1024) {
   46:     die('skip Not enough memory.');
   47:   }
   48: }
   49: ?>
   50: --INI--
   51: memory_limit=2100M
   52: --FILE--
   53: <?php
   54: $a1 = str_repeat("1", 1024 * 1024 * 1024 * 0.5);
   55: echo "1\n";
   56: $a2 = str_repeat("2", 1024 * 1024 * 1024 * 0.5);
   57: echo "2\n";
   58: $a3 = str_repeat("3", 1024 * 1024 * 1024 * 0.5);
   59: echo "3\n";
   60: $a4 = str_repeat("4", 1024 * 1024 * 1024 * 0.5);
   61: echo "4\n";
   62: $a5 = str_repeat("5", 1024 * 1024 * 1024 * 0.5);
   63: echo "5\n";
   64: ?>
   65: --EXPECTF--
   66: 1
   67: 2
   68: 3
   69: 4
   70: 
   71: Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %sbug55509.php on line %d

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>