[php-src] Issue #21450: preg_match(): Allocation of JIT memory failed - caused by systemd MemoryDenyWriteExecute

From: Date: Sun, 15 Mar 2026 01:56:23 +0000
Subject: [php-src] Issue #21450: preg_match(): Allocation of JIT memory failed - caused by systemd MemoryDenyWriteExecute
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251808@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/21450 Author: RichardNeill ### Description This isn't a PHP bug, but a bug caused by the interoperation of PHP 8.5 and Apache, when systemd is set to be more restrictive. This occurs in Ubuntu 26.04 ("Resolute Raccoon") - i.e. it's going to be a default problem for a lot of people quite soon. I'm filing it here, so that others can find it (as it took me hours to figure out). 1. The error message is: ``Warning: preg_match(): 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 in [MY PHP FILENAME]`` 2. Root cause: the way JIT works is to write to memory, then compile the Regex, then make that memory executable. This falls foul of one of the stricter protections added to systemd, namely: `MemoryDenyWriteExecute` 3. To fix the problem, do `sudo systemctl edit apache2` and add the lines ``` [Service] MemoryDenyWriteExecute=no ``` then save and restart apache. 4. See also: https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/2144455 5. May I request a comment on whether the right thing to do is to disable PHP's JIT, or whether it is in fact safe to remove that recently added systemd restriction. Thanks. ### PHP Version ```plain PHP 8.5.2 (cli) (built: Jan 21 2026 17:35:28) (NTS) Copyright (c) The PHP Group Built by Ubuntu Zend Engine v4.5.2, Copyright (c) Zend Technologies with Xdebug v3.5.0, Copyright (c) 2002-2025, by Derick Rethans with Zend OPcache v8.5.2, Copyright (c), by Zend Technologies Using libapache2-mod-php8.5 . ``` ### Operating System Ubuntu 26.04

« previous php.bugs (#251808) next »