zts build segfault
Describe the bug
I'm not sure if this is meant to work or not, but the php+apache setup we use has thread-safe builds of php modules.
I built apm-agent-php with thread-safety, I see startup messages from the module, but it does nothing (no debug/trace logs) when a script is executed.
However, if I phpinfo() it will segfault.
OS: centos 7 php: 7.4.20 apm-agent-php: 1.1
To Reproduce Steps to reproduce the behavior:
- Build zts module:
zts-phpize
CFLAGS="-std=gnu99" ./configure --enable-elastic_apm --with-php-config=/usr/bin/zts-php-config
make clean
make install
echo "extension=elastic_apm.so" > /etc/php-zts.d/98-elastic-apm.ini
echo "elastic_apm.bootstrap_php_part_file=/opt/elastic/apm-agent-php/src/bootstrap_php_part.php" >> /etc/php-zts.d/98-elastic-apm.ini
- Then call phpinfo() in a script
- See segfault
- (or)
<?php echo "hello world"; - No tracing happens
Expected behavior Tracing and no segfault
If it helps, here is a Dockerfile which demonstrates the issue:
FROM centos:7
CMD ["/usr/sbin/httpd", "-DFOREGROUND"]
#php + apache 2.4 (NB that codeit.guru provides an updated apache, but also causes zts variants of modules to be loaded)
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
http://rpms.remirepo.net/enterprise/remi-release-7.rpm \
unzip \
wget \
&& cd /etc/yum.repos.d \
&& wget https://repo.codeit.guru/codeit.el`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo \
&& yum-config-manager --enable remi-php74 \
&& yum install -y \
php \
&& yum clean all
#build elastic apm-agent-php zts
RUN mkdir -p /opt/elastic/ \
&& cd /tmp \
&& wget https://github.com/elastic/apm-agent-php/archive/refs/tags/v1.1.zip \
&& unzip v1.1.zip -d /opt/elastic/ \
&& mv /opt/elastic/apm-agent-php-1.1 /opt/elastic/apm-agent-php \
&& rm *.zip \
&& cd /opt/elastic/apm-agent-php/src/ext \
&& yum install -y php-devel curl-devel \
&& zts-phpize \
&& CFLAGS="-std=gnu99" ./configure --enable-elastic_apm --with-php-config=/usr/bin/zts-php-config \
&& make clean \
&& make \
&& make install \
&& echo "extension=elastic_apm.so" > /etc/php-zts.d/98-elastic-apm.ini \
&& echo "elastic_apm.bootstrap_php_part_file=/opt/elastic/apm-agent-php/src/bootstrap_php_part.php" >> /etc/php-zts.d/98-elastic-apm.ini
# test files, redirect apache logs
RUN echo "<?php phpinfo();" > /var/www/html/index.php \
&& echo "<?php echo 'hello world';" > /var/www/html/test.php \
&& sed -i 's/logs\/access_log/\/dev\/stdout/' /etc/httpd/conf/httpd.conf \
&& sed -i 's/logs\/error_log/\/dev\/stderr/' /etc/httpd/conf/httpd.conf
FYI this is super-low priority for us, I changed our docker image to not use zts to work around this issue.
We don't have near term plans to support ZTS mode.