php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60266 Stack overflow makes PHP crash with Segmentation Fault
Submitted: 2011-11-11 13:14 UTC Modified: 2011-11-11 14:52 UTC
From: smh at wannafind dot dk Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.4.0RC1 OS: Linux 2.6.18-194.26.1.el5
Private report: No CVE-ID: None
 [2011-11-11 13:14 UTC] smh at wannafind dot dk
Description:
------------
Whenever a PHP script encounters a stack overflow, it just dies with a message to 
stderr stating: "Segmentation fault".

Test script:
---------------
#!/usr/local/bin/php
<?php
function segmentationFaultFunction()
{
    static $counter;
    echo ++$counter . ' ';
    $func = function(){
        return segmentationFaultFunction();
    };
    $func->__invoke();
    return $func;
}
$function = segmentationFaultFunction();
$function->__invoke();
echo 'Done, no segmentation faults' . PHP_EOL;

Expected result:
----------------
I expected my error handler to be called with a stack trace.

The best solution would be if PHP registers the error before crashing and throws 
an exception with the stack trace.

The second best solution would be if PHP could give us a better error description 
than Segmentation fault. Maybe just terminate the script with an error that looks 
like this: "Stack overflow in file: /scripts/test.segfault.php on line 10".

Actual result:
--------------
Script terminates with an uncatchable  error to stdout: "Segmentation fault".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-11 14:52 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You're having an infinite recursion. This recursion leads to an stack overflow. This causes the operating system to terminate the process. Nothing PHP can fix.
 [2011-11-11 14:52 UTC] johannes@php.net
-Status: Open +Status: Bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 23:01:29 2024 UTC