xref: /PHP-5.3/tests/output/bug63377.phpt (revision 56d9edbb)
1--TEST--
2Bug #63377 (Segfault on output buffer > 2GB)
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE == 4) {
6  die('skip Not for 32-bits OS');
7}
8
9$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
10if ($zend_mm_enabled === "0") {
11    die("skip Zend MM disabled");
12}
13
14if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
15// check the available memory
16if (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 < 3072*1024*1024) {
27    die('skip Not enough memory.');
28  }
29}
30elseif (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 < 3072*1024*1024) {
46    die('skip Not enough memory.');
47  }
48}
49?>
50--FILE--
51<?php
52ini_set('memory_limit', '3072M');
53
54ob_start();
55for ($i = 0; $i < 22; $i++)  {
56        echo str_repeat('a', 100 * 1024 * 1024);
57}
58ob_end_clean();
59echo "okey";
60?>
61--EXPECTF--
62okey
63