#19429 [Csd->Bgs]: Using $GLOBALS in the global variable scope causes a segmentation fault

From: Date: Mon, 16 Sep 2002 11:59:03 +0000
Subject: #19429 [Csd->Bgs]: Using $GLOBALS in the global variable scope causes a segmentation fault
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-19443@lists.php.net to get a copy of this message
ID: 19429 Updated by: sniper@php.net Reported By: dragon@wastelands.net -Status: Closed +Status: Bogus Bug Type: Reproducible crash Operating System: Slackware Linux 2.4.5 PHP Version: 4.2.2 New Comment: 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 $). Previous Comments: ------------------------------------------------------------------------ [2002-09-16 04:48:49] dragon@wastelands.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 04:29:41] dragon@wastelands.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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19429&edit=1

« previous php.bugs (#19443) next »