php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19429 Using $GLOBALS in the global variable scope causes a segmentation fault
Submitted: 2002-09-16 04:29 UTC Modified: 2002-09-16 06:59 UTC
From: dragon at wastelands dot net Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 4.2.2 OS: Slackware Linux 2.4.5
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: dragon at wastelands dot net
New email:
PHP Version: OS:

 

 [2002-09-16 04:29 UTC] dragon at wastelands dot net
I typically write my code on a local machine running 4.1.2.  The following code works fine on my local machine, but causes a segmentation fault in the apache child sending the page, which is on the server using 4.2.2.

The offending line was:

foreach ($vars as $var) if ($GLOBALS["$var"]) { $prosql = 1; $websql = 1; }

Obviously it is quite stupid trying to access global variables like this from within the global scope, but this line got moved from a function at some stage and obviously I didn't change it.

Anyways -- stupid code shouldn't crash the server.  and it took me long enough to even find the offending line.

changing the middle part to "if ($var)" promptly fixed the problem.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-16 04:48 UTC] dragon at wastelands dot net
ok obviously the ($var) isnt actually referencing the global variable, so this wasn't the problem.  im still trying to work out the real problem (seems to be accessing an array from a form submission which has nothing in it) but I will post a separate bug report when I work out exactly what is wrong.
 [2002-09-16 06:59 UTC] sniper@php.net
In PHP 4.2.0, the 'register_globals' setting default changed to
'off'. See http://www.php.net/release_4_2_0.php for more info.
We are sorry about the inconvenience, but this change was a necessary
part of our efforts to make PHP scripting more secure and portable.


And $GLOBALS["$var"] should be $GLOBALS['var'] (without the $).

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 01:01:33 2025 UTC