php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78903 Conflict in RTD key for closures results in crash
Submitted: 2019-12-03 20:50 UTC Modified: 2019-12-13 12:11 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: chartjes at grumpy-learning dot com Assigned: nikic (profile)
Status: Closed Package: Reproducible crash
PHP Version: 7.4.0 OS: macOS 10.15.1
Private report: No CVE-ID: None
 [2019-12-03 20:50 UTC] chartjes at grumpy-learning dot com
Description:
------------
I have been testing out PHP 7.4 with OpenCFP (https://github.com/opencfp/opencfp) and my test suite that uses PHPUnit is crashing with "Allowed memory size" errors that do not occur when using PHP 7.3.

I am using PHP 7.4.0 installed using Homebrew

Here are the modules that are installed

[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
phpdbg_webhelper
posix
pspell
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

My default memory_limit setting is 768M

I get the following error:

PHP Fatal error:  Allowed memory size of 805306368 bytes exhausted (tried to allocate 20480 bytes)

If I change memory_limit to be 1024M I get "bus error" when running the tests


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-03 21:38 UTC] derick@php.net
-Status: Open +Status: Feedback
 [2019-12-03 21:38 UTC] derick@php.net
It'd be really helpful if you explained how to run the test suite in there. I also thought you mentioned memory_limit=-1 and a bus error? The latter comes with segfault usually, which you can make with gdb: https://bugs.php.net/bugs-generating-backtrace.php

You can run that as:
gdb --args php `which phpunit`

And then "run" on the gdb prompt
 [2019-12-03 22:46 UTC] chartjes at grumpy-learning dot com
The command I use to run the integration test suite is:

SYMFONY_DEPRECATIONS_HELPER=disabled CFP_ENV=testing vendor/bin/phpunit --testsuite integration

If I set memory_limit in my phpunit.xml file to be -1, it crashes with a bus error.

gdb has issues on macOS Catalina where it needs to be codesigned and I have tried numerous fixes to get it to work and have been unsuccessful.
 [2019-12-03 22:52 UTC] cmb@php.net
-Status: Feedback +Status: Open
 [2019-12-04 07:17 UTC] nikic@php.net
Can't reproduce memory limit / bus error, presumably because the test suite does not work correctly: I get a lot of "RuntimeException: The config file "/home/nikic/repos/opencfp/config/testing.yml" does not exist" errors.
 [2019-12-04 07:32 UTC] nikic@php.net
After creating a cfp_test mysql user and database and running "make integration" first, I now get:

Fatal error: Allowed memory size of 805306368 bytes exhausted at /home/nikic/php-7.4/Zend/zend_hash.c:2079 (tried to allocate 1048616 bytes) in /home/nikic/repos/opencfp/vendor/fzaninotto/faker/src/Faker/Provider/Text.php on line 84

I was not able to set memory_limit=-1 to produce the bus error, because the test runner apparently ignores ini files and options specified on the command line.
 [2019-12-04 08:33 UTC] nikic@php.net
Turns out the memory_limit is set in the phpunit.xml.dist, and removing it there does produce a segfault. There is no useful trace because a corrupted function causes a jump to an invalid address. Unfortunately there are no warnings under valgrind.
 [2019-12-04 13:25 UTC] chartjes at grumpy-learning dot com
My apologies for not providing clearer instructions for running the tests.

You could copy phpunit.xml.dist to phpunit.xml and change the memory_limit value in there, which the tests will then use.
 [2019-12-11 11:29 UTC] nikic@php.net
Initial analysis suggests that this is caused by an RTD key collision. While a closure is being executed, the file that defines the closure is re-compiled and a colliding RTD key is generated, replacing the original closure. This is a long-standing problem without an easy fix, but we can at least mitigate this in a similar way we do for anon classes.

This likely also indicates a bug/inefficiency in Laravel, because it likely shouldn't be loading the same file twice.

[0x7fac0481b5d0] Illuminate\Database\Eloquent\Factory->load("/home/nikic/repos/opencfp/tests/../factories") /home/nikic/repos/opencfp/vendor/illuminate/database/Eloquent/Factory.php:202 
[0x7fac0481b500] Illuminate\Database\Eloquent\Factory->construct(object[0x7fac0481b550], "/home/nikic/repos/opencfp/tests/../factories") /home/nikic/repos/opencfp/vendor/illuminate/database/Eloquent/Factory.php:54 
[0x7fac0481b310] factory(object[0x7fac0481b360]) /home/nikic/repos/opencfp/tests/helpers.php:28 
[0x7fac0481b280] Illuminate\Database\Eloquent\Factory->{closure}() /home/nikic/repos/opencfp/factories/Common.php:36
 [2019-12-11 12:05 UTC] nikic@php.net
-Summary: "Allowed memory size" and "bus error" crashes in 7.4 that do not appear in 7.3 +Summary: Conflict in RTD key for closures results in crash
 [2019-12-11 12:08 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b55033fa18afd9bb60fc4537270266d808ec0868
Log: Fixed bug #78903: Conflict in RTD key for closures results in crash
 [2019-12-11 12:08 UTC] nikic@php.net
-Status: Open +Status: Closed
 [2019-12-11 12:10 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2019-12-11 12:10 UTC] nikic@php.net
Tests run through now with one failure that also exists on 7.3:

1) OpenCFP\Test\Integration\Http\Controller\Admin\SpeakersControllerTest::indexActionWorksCorrectly

Warning: sprintf(): Too few arguments in /home/nikic/repos/opencfp/vendor/codedungeon/phpunit-result-printer/src/ResultPrinter71.php on line 77

/home/nikic/repos/opencfp/tests/Helper/ResponseHelper.php:60
/home/nikic/repos/opencfp/tests/Integration/Http/Controller/Admin/SpeakersControllerTest.php:43
 [2019-12-11 13:40 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=502cd7b1f154cd58d53e1a7415b8900e76aa6cea
Log: Revert "Fixed bug #78903: Conflict in RTD key for closures results in crash"
 [2019-12-11 13:42 UTC] nikic@php.net
-Status: Closed +Status: Re-Opened
 [2019-12-11 13:42 UTC] nikic@php.net
Reverted because it breaks ext/opcache/tests/bug65915.phpt.
 [2019-12-13 12:11 UTC] nikic@php.net
-Status: Re-Opened +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC