From d9e71169e6c0d8cd33e44f5e6a1d1ec3926f3362 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 5 Feb 2018 21:08:18 +0100 Subject: [PATCH] Fixed bug #75729 Don't try to evaluate substr() and strpos() at compile-time if mbstring function overloading is enabled. I'm reusing the COMPILE_NO_BUILTIN_STRLEN for the detection of mbstring function overloading here, even if it's technically only about strlen()... --- NEWS | 3 +++ ext/opcache/Optimizer/sccp.c | 6 ++++-- ext/opcache/tests/bug75729.phpt | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 ext/opcache/tests/bug75729.phpt diff --git a/NEWS b/NEWS index fde430f530..2934990161 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,9 @@ PHP NEWS - ODBC: . Fixed bug #73725 (Unable to retrieve value of varchar(max) type). (Anatol) +- Opcache: + . Fixed bug #75729 (opcache segfault when installing Bitrix). (Nikita) + - Standard: . Fixed bug #75916 (DNS_CAA record results contain garbage). (Mike, Philip Sharp) diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c index abb4664475..c3c719c1bd 100644 --- a/ext/opcache/Optimizer/sccp.c +++ b/ext/opcache/Optimizer/sccp.c @@ -695,7 +695,8 @@ static inline int ct_eval_func_call( } else if (zend_string_equals_literal(name, "strpos")) { if (Z_TYPE_P(args[0]) != IS_STRING || Z_TYPE_P(args[1]) != IS_STRING - || !Z_STRLEN_P(args[1])) { + || !Z_STRLEN_P(args[1]) + || (CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN)) { return FAILURE; } /* pass */ @@ -774,7 +775,8 @@ static inline int ct_eval_func_call( /* pass */ } else if (zend_string_equals_literal(name, "substr")) { if (Z_TYPE_P(args[0]) != IS_STRING - || Z_TYPE_P(args[1]) != IS_LONG) { + || Z_TYPE_P(args[1]) != IS_LONG + || (CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN)) { return FAILURE; } /* pass */ diff --git a/ext/opcache/tests/bug75729.phpt b/ext/opcache/tests/bug75729.phpt new file mode 100644 index 0000000000..1bf238352b --- /dev/null +++ b/ext/opcache/tests/bug75729.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #75729: opcache segfault when installing Bitrix +--SKIPIF-- + +--INI-- +opcache.enable_cli=1 +mbstring.func_overload=2 +--FILE-- + +--EXPECT-- +Deprecated: The mbstring.func_overload directive is deprecated in Unknown on line 0 +int(1) -- 2.50.1