Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Allocation of JIT memory failed, PCRE JIT will be disabled" warning in PHP 7

I'm transitioning my website from PHP v.5 installed on a shared web-hosting account (at DreamHost) to run on PHP 7.3.11. After transition, I started noticing that once in a while I get these warnings:

Warning: preg_match_all(): Allocation of JIT memory failed, PCRE JIT will be disabled. This is likely caused by security restrictions. Either grant PHP permission to allocate executable memory, or set pcre.jit=0

The last one originated from this line of code that was supposed to replace special tags in my posted HTML for the page:

if(preg_match_all("/\[".$tagBegin."(\S)+\]/U", $html, $matches, PREG_OFFSET_CAPTURE) !== false)

Is there something that I need to do differently in v.7.3 to avoid that warning?

like image 372
c00000fd Avatar asked Dec 08 '19 01:12

c00000fd


2 Answers

You should be able to ward off this warning by using ini_set to change the config value suggested by the warning message itself:

ini_set("pcre.jit", "0");

Be sure to run that line of code before any usages of regular expressions.

like image 121
Alan H. Avatar answered Sep 29 '22 01:09

Alan H.


For me I have added pcre.jit=0 to php.ini file in [Pcre] and this worked very nice.

like image 44
Ruberandinda Patience Avatar answered Sep 29 '22 01:09

Ruberandinda Patience