What is wrong with this code? It works when $it = 1000
but fails with Segmentation fault: 11
when $it > 8000
. There is neither a script timeout nor memory exhausted. Setting high memory_limit
makes no difference.
$it = 10000;
$middleware = function($chain) {
$chain();
};
$chain = function() use (&$chain, $it, $middleware) {
static $index = 0;
if ($index++ < $it) {
$middleware($chain);
}
};
$chain();
My system is PHP 5.6.16
with the following extensions:
Core, date, ereg, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2,
calendar, ctype, dom, hash, fileinfo, filter, ftp, gd, gettext, SPL,
iconv, json, ldap, mbstring, session, standard, mysqlnd, pcntl,
mysqli, PDO, pdo_mysql, pdo_sqlite, Phar, posix, Reflection, mysql,
shmop, SimpleXML, soap, sockets, exif, sysvmsg, sysvsem, sysvshm,
tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, zip, curl,
gmp, igbinary, imap, intl, mcrypt, memcache, memcached, mongo,
mssql, OAuth, pdo_dblib, pdo_pgsql, pgsql, propro, raphf, readline,
redis, solr, ssh2, xsl, http, mhash, xdebug
$chain
everywhere, it makes it rather painful to parse.xdebug.max_nesting_level
i lower than$it