php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13259 Unsetting a global var inside a function not working (can crash)
Submitted: 2001-09-12 01:21 UTC Modified: 2001-10-08 09:01 UTC
From: warwick at imvs dot sa dot gov dot au Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 4.0.6 OS: Linux (Redhat 7.1 & 6.2)
Private report: No CVE-ID: None
 [2001-09-12 01:21 UTC] warwick at imvs dot sa dot gov dot au
In a (bad) block of code I found the HTTP process to crash every time with the Zend Optimizer (v1.1.0) enabled in PHP 4.0.6.  The same version of Zend Optimizer does not crash in 4.0.5, however I think this is more a PHP issue than the Optimizer's.  

Code sample:

<?php
$globalVar = "Hello world";
clearGlobal();
echo "After clear = $globalVar";

function clearGlobal()
{
    global $globalVar;
    unset ($GLOBALS['globalVar']);
}
?>

With or without the Zend Optimizer enabled, the 'echo' statement displays crap (in both 4.0.5 & 4.0.6), rather than an empty value.  However, with the Zend Optimizer enabled it actually causes the HTTP process to crash in 4.0.6. 

My build command for PHP is currently:
./configure  --with-mysql=/usr/local/mysql --enable-track-vars --with-apxs=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-zlib

(I have rebuilt PHP without the zlib extension and it makes no difference)

-------------------------------------------------------
GDB Backtrace:

Starting program: /usr/local/apache-1.3.12/bin/httpd -X

Program received signal SIGSEGV, Segmentation fault.
0x4025dee5 in zend_reverse_table ()
   from /usr/local/apache/libexec/ZendOptimizer.so
(gdb) bt
#0  0x4025dee5 in zend_reverse_table ()
   from /usr/local/apache/libexec/ZendOptimizer.so
#1  0x40264513 in zend_reverse_table ()
   from /usr/local/apache/libexec/ZendOptimizer.so
#2  0x40271b35 in zend_reverse_table ()
   from /usr/local/apache/libexec/ZendOptimizer.so
#3  0x4027501d in zend_oe () from /usr/local/apache/libexec/ZendOptimizer.so
#4  0x403b7130 in zend_execute_scripts (type=8, file_count=3) at zend.c:752
#5  0x403c85db in php_execute_script (primary_file=0xbffff818) at main.c:1206
#6  0x403c4e86 in apache_php_module_main (r=0x80ef48c, display_source_mode=0)
    at sapi_apache.c:89
#7  0x403c5811 in send_php (r=0x80ef48c, display_source_mode=0, filename=0x0)
    at mod_php4.c:536
#8  0x403c583a in send_parsed_php (r=0x80ef48c) at mod_php4.c:547
#9  0x080542e3 in ap_invoke_handler () at eval.c:41
#10 0x08067819 in process_request_internal () at eval.c:41
#11 0x0806787c in ap_process_request () at eval.c:41
#12 0x0805f11e in child_main () at eval.c:41
#13 0x0805f2ac in make_child () at eval.c:41
#14 0x0805f409 in startup_children () at eval.c:41
#15 0x0805fa36 in standalone_main () at eval.c:41
#16 0x080601c3 in main () at eval.c:41
#17 0x4009a177 in __libc_start_main (main=0x805fe7c <main>, argc=2, 
    ubp_av=0xbffffa3c, init=0x804e864 <_init>, fini=0x809419c <_fini>, 
    rtld_fini=0x4000e184 <_dl_fini>, stack_end=0xbffffa34)
    at ../sysdeps/generic/libc-start.c:129

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-12 02:57 UTC] joey@php.net
I am unable to duplicate this using latest CVS...can you check
a recent snapshot to see if this is fixed?
 [2001-10-08 09:01 UTC] sander@php.net
No feedback. Closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 23:01:32 2024 UTC