notes icon indicating copy to clipboard operation
notes copied to clipboard

PHP 7.3 JIT compilation failed: no more memory

Open lanlin opened this issue 6 years ago • 3 comments

场景

升级到 PHP 7.3.0 之后,运行 preg_* 系列的内置函数,会出现类似下面的报错。

Warning: preg_match(): JIT compilation failed: no more memory in xxx
Warning:  preg_match(): JIT compilation failed: no more memory in xxx
Warning:  preg_split(): JIT compilation failed: no more memory in xxx
Warning:  preg_replace(): JIT compilation failed: no more memory in xxx

[ErrorException]                                          
preg_match_all(): JIT compilation failed: no more memory
...

原因

这是 PHP 7.3.0 本身的一个 BUG 引起的, 详见 Bug #77260 | preg_match_all(): JIT compilation failed: no more memory

临时解决方案

找到 php.ini 中的 ;pcre.jit=1 的这个地方:

 ; Enables or disables JIT compilation of patterns. This requires the PCRE
 ; library to be compiled with JIT support.
 ;pcre.jit=1

放开注释改为 pcre.git=0 也就是 disable 掉这个配置:

 ; Enables or disables JIT compilation of patterns. This requires the PCRE
 ; library to be compiled with JIT support.
 pcre.jit=0

修改保存后,记得重启你的 php-fpm. 然后静等官方修复 bug....

lanlin avatar Dec 14 '18 01:12 lanlin

貌似只有在 macOS 上會發生?

mingtsay avatar Jan 25 '19 10:01 mingtsay

好像是的。

lanlin avatar Jan 28 '19 01:01 lanlin

截止 PHP 7.3.2 问题仍然没有解决。

lanlin avatar Feb 12 '19 10:02 lanlin