Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: "Warning: preg_replace() [function.preg-replace]: 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" #32

Open
torbengb opened this issue Oct 21, 2020 · 7 comments
Assignees
Labels
1prio HIGH Issues that need urgent attention. bug Something isn't working

Comments

@torbengb
Copy link
Owner

No description provided.

@torbengb torbengb added bug Something isn't working 1prio HIGH Issues that need urgent attention. labels Oct 21, 2020
@torbengb torbengb self-assigned this Oct 21, 2020
@torbengb
Copy link
Owner Author

torbengb commented Oct 21, 2020

This error is known to occur on DreamHost shared hosting servers. Solution is to add a line to the hosting's php.ini (source).

Add this line to /home/username/.php/7.4/phprc:

; added following 1 line to adress the error, based on solution here: https://stackoverflow.com/a/59299425/20571:
; Warning: preg_replace() [function.preg-replace]: 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
ini_set('pcre.jit', '0')

After this change, need to kill off any running PHP processes: https://help.dreamhost.com/hc/en-us/articles/214200748-My-phprc-file-isn-t-updating :

  • For PHP 7.4: [server]$ killall -9 php74.cgi -u shelluser
  • or via the DH panel, go to Manage Domains, click on 'edit' for that domain, then click 'Change settings' and wait 10 minutes.

@torbengb
Copy link
Owner Author

Testing confirms the above was successful.

@AlbertHart
Copy link

Is there a tic mark missing in: ini_set('pcre.jit, '0')

@torbengb
Copy link
Owner Author

You are correct, it should read:

ini_set('pcre.jit', '0')

and I corrected it in the post above.

@torbengb
Copy link
Owner Author

Reopen:This problem persists. It can be temporarily solved with the fix mentioned above, but within (30?) minutes the issue reappears.
Need to find permanent solution.

@torbengb torbengb reopened this Nov 14, 2020
@AlbertHart
Copy link

I agree. I worked with Dreamhost to get my php.ini file correct, but the issue keeps reoccuring.

I have filtered for it and removed it's display with code like this. It suppresses the JIT error but report other errors to me.

PHP's log_error() lets me override the error message process.
rp_error() is my own error display routine.

function log_error($no,$msg,$file,$line)
        {
            $error_message = "Error no $no: $msg in $file at line number $line";
            //rp_report("log_error STRPOS: %s", strpos($msg, "Allocation of JIT memory failed"));
            // Allocation of JIT memory failed,
            if (strpos($msg, "Allocation of JIT memory failed") !== false)
            {
                return;
            }
            else
            {
                rp_error("log_error PHP ERROR: %s", $error_message);
            }
        }

@AlbertHart
Copy link

I discovered today, after chatting with Dreamhost, that setting

ini_set('pcre.jit', '0')

(or any phprc settings)

does not work in PHP 7.4 in Dreamhost.

So I reverted back to 7.3 and was able to get pcre.jit set to 0.

From phpinfo();

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1prio HIGH Issues that need urgent attention. bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants