[Bug 268318] www/apache24 with www/mod_php82: opcache + ASLR turned on crashes Apache

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 05 May 2023 09:20:26 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268318

--- Comment #18 from Miroslav Lachman <000.fbsd@quip.cz> ---
(In reply to Vladimir Druzenko from comment #15)
As many of you I see Apache httpd crashes after OS upgrade to 13.2-RELEASE.
According to gdb it crashed in opcache.so (PHP extension Opcache)

#0  0x000000083e878950 in ?? ()
(gdb) bt
#0  0x000000083e878950 in ?? ()
#1  0x0000000841c37c52 in ?? () from /usr/local/lib/php/20210902/opcache.so
#2  0x000000083f27ec46 in ?? () from /usr/local/libexec/apache24/libphp.so
#3  0x000000083f260a12 in zend_llist_apply_with_del ()
   from /usr/local/libexec/apache24/libphp.so
#4  0x000000083f1fedd8 in php_module_startup () from
/usr/local/libexec/apache24/libphp.so
#5  0x000000083f35c995 in ?? () from /usr/local/libexec/apache24/libphp.so
#6  0x000000083f35c1e6 in ?? () from /usr/local/libexec/apache24/libphp.so
#7  0x00000000002620cf in ap_run_post_config ()
#8  0x000000000025d889 in main ()

Setting opcache.enable=0 in /usr/local/etc/php.ini helped as a quick
workaround.

I tried to disable ASLR for httpd with opcache enabled and in my case "elfctl
-e +noaslr /usr/local/sbin/httpd" works. No more crashes on SIGUSR1.

To disable ASLR for httpd Apache must not be running, otherwise you get an
error like this:
elfctl: error opening file /usr/local/sbin/httpd: Text file busy


The whole setup is something like this:

# service apache24 stop

# elfctl -e +noaslr /usr/local/sbin/httpd

# sed -i '' -E 's/^(opcache.enable *)=.*/\1=1/' /usr/local/etc/php.ini

# service apache24 start

# kill -USR1 `cat /var/run/httpd.pid`

# service apache24 status
apache24 is running as pid 50219.

# php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
hash
iconv
imap
intl
json
ldap
libxml
mbstring
mcrypt
memcached
mysqli
mysqlnd
openssl
pcre
PDO
pdo_dblib
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
ssh2
standard
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache


The only downside of this is invalidated package checksum on
/usr/local/sbin/httpd

# pkg check -sa
Checking all packages:   1%
apache24-2.4.56: checksum mismatch for /usr/local/sbin/httpd
Checking all packages: 100%

Checksum can be recalculated by pkg check -r or pkg check --recompute.

And "elfctl -e +noaslr /usr/local/sbin/httpd" must be executed after each
Apache upgrade / reinstall.

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