Description
Hello,
I have an issue, and I think it's related to apcu, and more specially to the apc.coredump_unmap=On option. I got an issue with php (fixed with the upgrade of php from 8.3.14 to 8.3.19) but because I have read that apc.coredump_unmap can help to see what's going on in case of segfault, I activate it. But then, after the upgrade I was still seeing some segfault. But once I disabled the option, the issue disappear.
I see the segfault occurs when I check the status page of php-fpm (but I assume it's a side effect).
So here is my case to reproduce it. Sorry, I got no extra time to narrower it more.
The issue occurs in 8.3.19 -> 8.3.21(last 8.3). But In 8.4.7 I got no issue.
So here is my docker compose file
services:
php-dbg:
platform: linux/amd64
build:
dockerfile: ./Dockerfile
target: php_base
extra_hosts:
- "host.docker.internal:host-gateway"
tty: true
php-fpm-status-dbg:
image: hipages/php-fpm_exporter
command:
- --phpfpm.scrape-uri=tcp://php-dbg:9001/_status
depends_on:
- php-dbg
prometheus:
image: prom/prometheus:v2.53.3
command:
- --config.file=/etc/prometheus.yaml
- --web.enable-remote-write-receiver
- --enable-feature=exemplar-storage
- --enable-feature=native-histograms
volumes:
- ./docker/opentelemetry/prometheus/prometheus.yaml:/etc/prometheus.yaml
ports:
- "9090:9090"
prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: [ 'localhost:9090' ]global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: [ 'localhost:9090' ]
- job_name: 'php-fpm-status-dbg'
static_configs:
- targets: ['php-fpm-status-dbg:9253']
scheme: http
metrics_path: /metrics
Dockerfile
#syntax=docker/dockerfile:1.4
ARG PHP_VERSION=8.3.21
FROM php:$PHP_VERSION-fpm-alpine AS php_upstream
FROM mlocati/php-extension-installer:2 AS php_extension_installer_upstream
FROM composer/composer:2-bin AS composer_upstream
FROM php_upstream AS php_base
WORKDIR /srv/app
RUN apk update && \
apk upgrade && \
apk add --no-cache \
acl \
fcgi \
file \
gettext \
git \
gnu-libiconv \
icu-libs \
icu-data-full \
linux-headers \
bash \
tzdata \
su-exec \
&& \
apk cache --no-interactive purge && \
rm -rf /var/cache/apk/*
COPY --from=php_extension_installer_upstream --link /usr/bin/install-php-extensions /usr/local/bin/
RUN set -eux; \
install-php-extensions \
apcu \
intl \
opcache \
zip
ENV TZ=Europe/brussels
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV PATH="${PATH}:/root/.composer/vendor/bin"
COPY --link zz-docker.conf /usr/local/etc/php-fpm.d/zz-docker.conf
COPY --link z-my.ini /usr/local/etc/php/conf.d/z-my.ini
COPY --link docker-entrypoint.sh /usr/local/bin/docker-entrypoint
COPY --from=composer_upstream --link /composer /usr/bin/composer
RUN mkdir storage && \
mkdir -p /var/run/php && \
chmod 0755 /usr/local/bin/docker-entrypoint && \
echo '<?php echo "hello";' > /srv/app/index.php
# expose status page
EXPOSE 9001
ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"]
z-my.ini
apc.enable_cli = 1
apc.coredump_unmap = On
date.timezone = Europe/Paris
session.auto_start = Off
short_open_tag = Off
zz-docker.conf
[global]
daemonize = no
process_control_timeout = 120
error_log = /proc/self/fd/2
log_level = notice
emergency_restart_threshold = 5
emergency_restart_interval = 1m
[www]
listen = /var/run/php/php-fpm.sock
listen.mode = 0666
ping.path = /ping
pm = dynamic
pm.max_children = 8
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 4
pm.max_requests = 150
pm.status_path = /_status
pm.status_listen = 0.0.0.0:9001
docker-entrypoint.sh
#!/bin/sh
set -ex
echo 'Entrypoint starting'
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- php-fpm "$@"
fi
RUN_AS=''
# when running php, php-fpm or bin/console do some extra stuff
if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
RUN_AS='www-data'
# add user to tty group to get the right to output
addgroup www-data tty
setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX /run/php
setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX /run/php
echo 'PHP app ready!'
fi
# launch php-fpm with limited user
if [ "$RUN_AS" != '' ]; then
su-exec "${RUN_AS}" docker-php-entrypoint "$@"
else
docker-php-entrypoint "$@"
fi