|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-08-18 15:24 UTC] sparkeh at btinternet dot com
Description:
------------
I've tried to get the code to the minimum required to cause a crash. The combination of the local variable being defined and the global reference seems to be causing stack corruption (the script never returns successfully from the function call:
jelly can # php -f crash.php
About to segfault : Segmentation fault
jelly can # php -v
PHP 5.0.1 (cli) (built: Aug 18 2004 12:39:38)
Reproduce code:
---------------
<?
switch($t)
{
default:
$rar = 0;
function segfault()
{
global $moo;
echo 'About to segfault : ';
}
segfault();
}
?>
Expected result:
----------------
About to segfault :
Actual result:
--------------
About to segfault : Segmentation fault
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 16:00:01 2025 UTC |
What loop?? Remove the "global $moo" and the $rar = 0 and it runs as expected: <? switch($t) { default: function segfault() { echo 'About to segfault : '; } segfault(); } echo 'Or not. Look no loop.'; ?>I getting a seg. fault on a simple little script that's worked for years and it sure smells like stack corruption. <? require_once("config.inc"); require_once("Database.inc"); $db = new Database(USER_ID, USER_PASSWORD); $db->connect(); $sql = "select from STUDENT_STATUS "; $sql .= "where STATUS='APPROVED' "; ?> On my solaris 9 x86 box this seq. faults. Change the last line it seq faults. Remove the last line it doesn't. After a hour of playing, I've discovered that I can prevent a seg. fault by place echo statements (or some other random statment) in key positions in the file. That sure smells like stack corruption. I ran gdb on the core dump and the last lines of the backtrace are: #20 0x81b65da in zend_deactivate () at /usr/local/src/php-5.0.1/Zend/zend.c:819 #21 0x8182007 in php_request_shutdown (dummy=0x0) at /usr/local/src/php-5.0.1/main/main.c:1212 #22 0x81db50f in main (argc=2, argv=0x8047a18) at /usr/local/src/php-5.0.1/sapi/cli/php_cli.c:1046 and from what little I know of gdb it looks like it's happening when php is trying to shutdown.