[Bug 268318] www/apache24 with www/mod_php8{0,1,2,3?}: opcache + ASLR turned on crashes Apache

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 13 Apr 2024 16:25:20 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268318

--- Comment #88 from Miroslav Lachman <000.fbsd@quip.cz> ---
(In reply to Fabian Wenk from comment #85)
This problem is more complicated with almost each release of Apache or PHP.

About a month ago I tried to debug the issue on 2 of our machines (just the 2
crashing, more than a dozen of others don't)

As a workaround Opcache can be disabled by opcache.enable=0 in php.ini but on
some workload the disabled Opcache is too bad for performance.

I was curious why it crashes on those 2 machines and not on the others, I
compared configuration in php.ini and the list of installed PHP extensions. I
thought there are some extra extensions which can cause the problem but it was
the other way around - 2 machines had fewer PHP extensions than other machines.
Once I installed more extensions it stoped crashing the Apache with Opcache
enabled. 
Then I tried to isolate minimalistic example and it was more complicated again.
Even only 2 extensions (one is opcache) can crash Apache on reload. 
The minimal set of extensions installed to have Apache without crashes was
this:

ext-10-opcache.ini
ext-18-session.ini
ext-20-bcmath.ini
ext-20-bz2.ini
ext-20-ctype.ini
ext-20-curl.ini
ext-20-dom.ini
ext-20-exif.ini
ext-20-fileinfo.ini
ext-20-filter.ini
ext-20-ftp.ini
ext-20-gd.ini
ext-20-iconv.ini
ext-20-intl.ini

Once I remove any of them the Apache will crash on reload with Opcache enabled.

The ftp PHP extension was one missing on the 2 mentioned machines.

But when you add bunch of PHP extensions then you play this game again because
it can start crashing again until you add even more extensions to stop it.

This problem is back again after the latest update of Apache to 2.4.59 on
different machines than before. 
3 machines where Apache crashed on reload with this version and unmodified list
of PHP extensions and unmodified php.ini.
The more interesting is that it crashes Apache with PHP 8.1 on 2 machines and
PHP 8.3 on third machine. The list of extensions is the same.

Again, it can be worked around by opcache.enable=0 but it is not a solution.
As the configuration of PHP is the same as bunch of other machines which do not
crash I started to dig deeper - the list of Apache modules. And there are some
differences. The main difference is that Apache with PHP with Opcache crashes
on machines where proxy_wstunnel_module is loaded! 
Once I commented out the LoadModule proxy_wstunnel_module in httpd.conf Apache
survived reload with PHP Opcache enabled. But we cannot disable wstunnel
because it is required by some web apps.
And things are still not clear enough. Another machine with
proxy_wstunnel_module loaded and with PHP Opcache enabled does not crashes
Apache on reload.

So ... there are too many things together which must match to make Apache
(don't) crash.

All tests were with this in rc.conf:
apache24_enable="YES"
apache24_aslr_disable="YES"
apache24_http_accept_enable="YES"

And in case of PHP 8.3 both PHP and mod_php were built with NOASLR = On.

-- 
You are receiving this mail because:
You are the assignee for the bug.