php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73759 segment fault when register_shutdown_function callback invoked
Submitted: 2016-12-16 14:12 UTC Modified: 2017-01-08 00:50 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: yywangzheng at 126 dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.6.29 OS: centos 7.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: yywangzheng at 126 dot com
New email:
PHP Version: OS:

 

 [2016-12-16 14:12 UTC] yywangzheng at 126 dot com
Description:
------------
//----------- main.php -----------
<?php
spl_autoload_register(function($class) {
    if ($class === 'MyClass') {
        include __DIR__ . '/MyClass.php';
    }
});
register_shutdown_function(function() {
    new MyClass;
});
require './error.php';

//----------- error.php -----------
<?php
$x = ['x'];
foreach ($x as $i) {
    $y[];
}

//----------- MyClass.php -----------
<?php
class MyClass {}

Expected result:
----------------
output:

PHP Fatal error:  Cannot use [] for reading in /Users/mike/bug/error.php on line 4

Fatal error: Cannot use [] for reading in /Users/mike/bug/error.php on line 4

Actual result:
--------------
output:
PHP Fatal error:  Cannot use [] for reading in /Users/mike/bug/error.php on line 4

Fatal error: Cannot use [] for reading in /Users/mike/bug/error.php on line 4
Segmentation fault: 11

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-20 06:33 UTC] laruence@php.net
-Status: Open +Status: Analyzed
 [2016-12-20 06:33 UTC] laruence@php.net
complier error leave CG(foreach_copy_stack) an unclean state, which cause the segfault in later try to complier MyClass.php(via autoloading).
 [2017-01-08 00:50 UTC] nikic@php.net
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: nikic
 [2017-01-08 00:50 UTC] nikic@php.net
Closing as this is fixed in PHP 7 (see https://3v4l.org/pnZHQ), while PHP 5.x is going out of active support.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 01:01:35 2025 UTC