|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-05-30 02:49 UTC] php at mattlight dot biz
Description: ------------ A segmentation fault occurs during garbage collection when the following criteria are all met: - Object "A" stores a reference to itself in an instance variable - Object "A" also stores another object, Object "B" in another instance variable (instance of stdClass is fine) - The destructor of object "A" attempts to reference object "B" only after check that object "B" is still set - Object "A" is instantiated from some other object The issue affects PHP 5.6 and 5.5 (and 5.4), but not 7.0. I have set the test case up in Travis CI: https://travis-ci.org/lightster/php-circular-reference-segfault The scenario I presented is a simplified scenario of an issue I encountered when using phpamqplib. Other people have reported this issue to phpamqplib but since the library is written purely in PHP it cannot be responsible for preventing a segmentation fault: https://github.com/php-amqplib/php-amqplib/issues/261 My bug report might be the same issue that was reported in https://bugs.php.net/bug.php?id=71958 but I was unable to confirm one way or another. Test script: --------------- https://raw.githubusercontent.com/lightster/php-circular-reference-segfault/master/segfault.php Expected result: ---------------- I would expect either "the object exists" or "will not get here" to be output. I know the order that destructors is called is documented to be undefined, so either output is probably acceptable. Actual result: -------------- PHP exits with a segmentation fault: Array ( [0] => Core [1] => date [2] => ereg [3] => libxml [4] => openssl [5] => pcre [6] => zlib [7] => filter [8] => hash [9] => pcntl [10] => readline [11] => Reflection [12] => SPL [13] => session [14] => standard [15] => mhash ) string(24) "we are about to segfault" string(15) "segfaults here:" Segmentation fault (core dumped) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 15:00:02 2025 UTC |
This error is still reproducible on my end with the latest version of PHP 5.6 (5.6.23). Here is the output I produced as of a few minutes ago: [boxkeeper@macaroon-dev php-circular-reference-segfault]$ php segfault.php Array ( [0] => Core [1] => date [2] => ereg [3] => libxml [4] => openssl [5] => pcre [6] => zlib [7] => filter [8] => hash [9] => pcntl [10] => readline [11] => Reflection [12] => SPL [13] => session [14] => standard [15] => mhash ) string(24) "we are about to segfault" string(15) "segfaults here:" Segmentation fault [boxkeeper@macaroon-dev php-circular-reference-segfault]$ echo $? 139 [boxkeeper@macaroon-dev php-circular-reference-segfault]$ php --version PHP 5.6.23 (cli) (built: Jun 22 2016 08:56:52) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies [boxkeeper@macaroon-dev php-circular-reference-segfault]$PHP Version is 5.6.30 Just launch your segfault.php script and I got: Array ( [0] => Core [1] => date [2] => ereg [3] => libxml [4] => openssl [5] => pcre [6] => zlib [7] => bcmath [8] => bz2 [9] => calendar [10] => ctype [11] => dba [12] => dom [13] => hash [14] => fileinfo [15] => filter [16] => ftp [17] => gettext [18] => SPL [19] => iconv [20] => mbstring [21] => pcntl [22] => session [23] => posix [24] => Reflection [25] => standard [26] => shmop [27] => SimpleXML [28] => soap [29] => sockets [30] => Phar [31] => exif [32] => sysvmsg [33] => sysvsem [34] => sysvshm [35] => tokenizer [36] => wddx [37] => xml [38] => xmlreader [39] => xmlwriter [40] => zip [41] => PDO [42] => curl [43] => gd [44] => json [45] => mcrypt [46] => mysql [47] => mysqli [48] => pdo_mysql [49] => readline [50] => ssh2 [51] => xmlrpc [52] => mhash ) string(24) "we are about to segfault" string(15) "segfaults here:" Segmentation fault (core dumped)PHP Version is 5.6.30 Just launch your segfault.php script and I got: Array ( [0] => Core [1] => date [2] => ereg [3] => libxml [4] => openssl [5] => pcre [6] => zlib [7] => bcmath [8] => bz2 [9] => calendar [10] => ctype [11] => dba [12] => dom [13] => hash [14] => fileinfo [15] => filter [16] => ftp [17] => gettext [18] => SPL [19] => iconv [20] => mbstring [21] => pcntl [22] => session [23] => posix [24] => Reflection [25] => standard [26] => shmop [27] => SimpleXML [28] => soap [29] => sockets [30] => Phar [31] => exif [32] => sysvmsg [33] => sysvsem [34] => sysvshm [35] => tokenizer [36] => wddx [37] => xml [38] => xmlreader [39] => xmlwriter [40] => zip [41] => PDO [42] => curl [43] => gd [44] => json [45] => mcrypt [46] => mysql [47] => mysqli [48] => pdo_mysql [49] => readline [50] => ssh2 [51] => xmlrpc [52] => mhash ) string(24) "we are about to segfault" string(15) "segfaults here:" Segmentation fault (core dumped)