php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65450 PHP 5.3.27 segfaults during shutdown
Submitted: 2013-08-14 15:52 UTC Modified: -
From: jakub dot lopuszanski at nasza-klasa dot pl Assigned:
Status: Open Package: CGI/CLI related
PHP Version: Irrelevant OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-08-14 15:52 UTC] jakub dot lopuszanski at nasza-klasa dot pl
Description:
------------
Follwing script outputs
"""
X

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 
72 bytes) in /home/jlopuszanski/test.php on line 8
B
Segmentation fault
"""
on php 5.3.27.
The problem is quite difficult to reproduce, as it greately depends on the 
filename, length of arguments etc.
Therefore I run it in a loop with different length of an argument passed to the 
script.
Sometimes uncommenting the line with echo "Y\n"; (even though it is obviously 
unreachable) helps to cause the error.
Sometimes I have to use ~/test.php or ./test.php instead of test.php as a 
filename to trigger the Segfault.

Once I find a good combination of filename and arguments, the problem is 
persistent and can be reproduced 100% of times for that combination.

Test script:
---------------
cat test.php
<?php
class A{
  function __construct(){
    register_shutdown_function(array(__CLASS__, 'handle_shutdown'));

    echo "X\n";
    while(1){
      $t[]=new B();
    }
 //   echo "Y\n";
  }
  static public function handle_shutdown(){
    echo "B\n";
    $b=new B();
    $b=null;
  }
}
class B{
}
$a=new A();
?>

for((n=0;n<100;++n));
do 
  echo $n;
  php-5.3.27/bin/php ~/test.php `for((i=0;i<n;++i));do echo -n a;done`;
done



Expected result:
----------------
X

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 
72 bytes) in /home/jlopuszanski/test.php on line 8
B


Actual result:
--------------
X

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 
72 bytes) in /home/jlopuszanski/test.php on line 8
B
Segmentation fault


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 23 16:01:26 2019 UTC