From: Nikita Popov Date: Wed, 29 May 2019 09:48:40 +0000 (+0200) Subject: Don't JIT functions with many blocks X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7a6430a52da182646844860a03fc6befbac8012;p=php Don't JIT functions with many blocks Avoids a stack overflow in Zend/tests/runtime_compile_time_binary_operands.php that happens in recursive RPO calculation. We could make that code non-recursive, but I don't think it makes sense to JIT this kind of function in the first place. --- diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 0d43576ed3..c6849cd3ac 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -599,6 +599,13 @@ static int zend_jit_build_cfg(zend_op_array *op_array, zend_cfg *cfg) return FAILURE; } + /* Don't JIT huge functions. Apart from likely being detrimental due to the amount of + * generated code, some of our analysis is recursive and will stack overflow with many + * blocks. */ + if (cfg->blocks_count > 100000) { + return FAILURE; + } + if (zend_cfg_build_predecessors(&CG(arena), cfg) != SUCCESS) { return FAILURE; }