php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72832 declare(ticks=1) and register_tick_function() together cause PHP7 to seg fault
Submitted: 2016-08-14 09:42 UTC Modified: 2020-03-22 04:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: brandon at ambitious dot tech Assigned: cmb (profile)
Status: No Feedback Package: Unknown/Other Function
PHP Version: 7.0.9 OS: Gentoo
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: brandon at ambitious dot tech
New email:
PHP Version: OS:

 

 [2016-08-14 09:42 UTC] brandon at ambitious dot tech
Description:
------------
PHP version: 7.0.9-r2
Configure line: './configure' '--prefix=/usr' '--build=x86_64-pc-linux-gnu' '--host=x86_64-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--docdir=/usr/share/doc/php-7.0.9-r2' '--htmldir=/usr/share/doc/php-7.0.9-r2/html' '--prefix=/usr/lib64/php7.0' '--mandir=/usr/lib64/php7.0/man' '--infodir=/usr/lib64/php7.0/info' '--libdir=/usr/lib64/php7.0/lib' '--with-libdir=lib64' '--localstatedir=/var' '--without-pear' '--enable-maintainer-zts' '--disable-bcmath' '--with-bz2=/usr' '--disable-calendar' '--enable-ctype' '--without-curl' '--disable-dom' '--without-enchant' '--disable-exif' '--disable-fileinfo' '--disable-filter' '--disable-ftp' '--with-gettext=/usr' '--without-gmp' '--enable-hash' '--without-mhash' '--with-iconv' '--disable-intl' '--disable-ipv6' '--enable-json' '--without-kerberos' '--disable-libxml' '--without-libxml-dir' '--enable-mbstring' '--with-mcrypt=/usr' '--with-onig=/usr' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--disable-pcntl' '--disable-phar' '--enable-pdo' '--disable-opcache' '--without-pgsql' '--enable-posix' '--without-pspell' '--without-recode' '--disable-simplexml' '--disable-shmop' '--without-snmp' '--disable-soap' '--disable-sockets' '--without-sqlite3' '--disable-sysvmsg' '--disable-sysvsem' '--disable-sysvshm' '--without-fpm-systemd' '--without-tidy' '--disable-tokenizer' '--disable-wddx' '--disable-xml' '--disable-xmlreader' '--disable-xmlwriter' '--without-xmlrpc' '--without-xsl' '--disable-zip' '--with-zlib=/usr' '--disable-debug' '--enable-dba' '--without-cdb' '--with-db4=/usr' '--disable-flatfile' '--without-gdbm' '--disable-inifile' '--without-qdbm' '--without-freetype-dir' '--disable-gd-jis-conv' '--without-jpeg-dir' '--without-png-dir' '--without-xpm-dir' '--without-gd' '--without-interbase' '--without-mysqli' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--without-unixODBC' '--without-iodbc' '--without-oci8' '--without-pdo-dblib' '--with-pdo-mysql=mysqlnd' '--without-pdo-pgsql' '--without-pdo-sqlite' '--without-pdo-firebird' '--without-pdo-odbc' '--without-pdo-oci' '--with-readline=/usr' '--without-libedit' '--without-mm' '--with-pic' '--with-pcre-regex=/usr' '--with-pcre-dir=/usr' '--with-config-file-path=/etc/php/apache2-php7.0' '--with-config-file-scan-dir=/etc/php/apache2-php7.0/ext-active' '--disable-embed' '--disable-cli' '--disable-cgi' '--disable-fpm' '--with-apxs2=/usr/bin/apxs' '--disable-phpdbg' 'build_alias=x86_64-pc-linux-gnu' 'host_alias=x86_64-pc-linux-gnu' 'CPPFLAGS='

Basically, the `declare(ticks=1);` line and `register_tick_function` line together cause PHP to throw a segmentation fault. Having just one line or the other works as expected. The function passed to register_ticks_function() doesn't seem to make any difference. I'm almost entirely sure PHP is throwing a seg fault because the Apache error logs say "AH00052: child pid YYYYY exit signal Segmentation fault (11)

Test script:
---------------
<?php

declare(ticks=1);
$ticks = 0;
register_tick_function(
	function() use (&$ticks){
		$ticks++;
	}
);

var_dump($ticks);

Expected result:
----------------
The result above should dump 0 or an int counting the number of ticks it takes ti run the code.

Actual result:
--------------
The actual result is that the web browser claims the page was reset and nothing is ever loaded.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-14 21:06 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2016-08-14 21:06 UTC] kalle@php.net
Is this only for Apache, and does this happen in non-TS builds? I remember back in 5.3 we did have some improvements to make ticks work in TS environments, but it could be a regression from 5.x
 [2016-08-15 05:40 UTC] brandon at ambitious dot tech
I disabled multi-threading, and the code worked just fine. I tried PHP cli, and it worked just fine there as well. After re-enabling threading, I found that the code doesn't work in Apache, however, it does work when run from the PHP cli.

Also, I'm not able to disable threading in just Apache or PHP with Gentoo, so I'm not sure if the bug is being caused by Apache's threading or PHP's threading. If there's anything else you need, let me know.
 [2016-08-28 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2016-08-28 04:25 UTC] requinix@php.net
-Status: No Feedback +Status: Open
 [2020-03-10 10:28 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-03-10 10:28 UTC] cmb@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
 [2020-03-22 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC