Disclaimer
The following issue does not represent a very common configuration and the issue may be specific to PHP implementation. Docker for Mac does play a role here though, as the problem does not exist natively AND PHP specifically was mentioned in https://github.com/docker/for-mac/issues/7117#issuecomment-1880565915.
We have been experiencing a very uncomfortable bug for months on Apple Silicon (checked on M2 and newer) - PHP binary fails execution in approx. 1 out of 10 runs, when opcache.huge_code_pages is enabled. A very simple script can replicate the issue:
while true; do
php -r 'return 0;'
if [ $? -ne 0 ]; then
break
fi
done
The execution ends with SIGILL (Illegal instruction). I'm attaching a coredump output (via gdb) from such random execution.
For reproduction, we verified the issue exists with the official PHP docker distribution and also when compiled from source inside the target Debian container (according to https://php.watch/articles/compile-php-ubuntu).
Description
Disclaimer The following issue does not represent a very common configuration and the issue may be specific to PHP implementation. Docker for Mac does play a role here though, as the problem does not exist natively AND PHP specifically was mentioned in https://github.com/docker/for-mac/issues/7117#issuecomment-1880565915.
We have been experiencing a very uncomfortable bug for months on Apple Silicon (checked on M2 and newer) - PHP binary fails execution in approx. 1 out of 10 runs, when
opcache.huge_code_pages
is enabled. A very simple script can replicate the issue:The execution ends with SIGILL (Illegal instruction). I'm attaching a coredump output (via gdb) from such random execution.
For reproduction, we verified the issue exists with the official PHP docker distribution and also when compiled from source inside the target Debian container (according to https://php.watch/articles/compile-php-ubuntu).
It turns out that the culprit is in enabling
opcache.huge_code_pages
(https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.huge_code_pages):(minimum configuration for reproduction in opcache.ini)
PHP version:
gdb-core-dump-1.txt
Reproduce
docker run -it php bash
(Inside the container)docker-php-ext-install opcache
echo "opcache.enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
echo "opcache.enable_cli=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
echo "opcache.huge_code_pages=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
while true; do php -r 'return 0;'; if [ $? -ne 0 ]; then break; fi; done
(wait for SIGILL)Expected behavior
Execution should not fail when huge pages are enabled.
docker version
docker info
Diagnostics ID
4979D611-045D-44A8-B78A-89F8778E7332/20240824144450
Additional Info
No response