php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70040 Losing globals and super-globals randomly when using frames.
Submitted: 2015-07-10 13:24 UTC Modified: 2015-07-16 16:37 UTC
From: phpqa at mathieuviau dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.0.0alpha2 OS: Ubuntu 14.04.2 LTS
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phpqa at mathieuviau dot com
New email:
PHP Version: OS:

 

 [2015-07-10 13:24 UTC] phpqa at mathieuviau dot com
Description:
------------
I have this legacy application still using frames with the same init code for the main page and for each of the frames in the main page.  Randomly, I get one or the other frames (not the main page) to loose information about some or all of the globals upon reloading the page multiple times.

I could not reproduce this when using a page without frames.

This is using the php7 module with apache2-mpm-prefork 2.4.7.
It occurs in both Chrome and Firefox (latest versions)

[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
gd
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter

[Zend Modules]


Test script:
---------------
Full set of source files available here:

http://www.mathieuviau.com/php-test-globals.tgz

** init.php **
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);

if (isset($_SERVER['SCRIPT_NAME'])) {
    $a = explode('/', $_SERVER['SCRIPT_NAME']);
} elseif (isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) {
    $a = explode('/', $HTTP_SERVER_VARS['SCRIPT_NAME']);
} else {
    var_dump(array_keys($GLOBALS));
    var_dump($_SERVER);
    debug_print_backtrace();
    $error = 'Unable to detect script environment.';
    die($error);
}

Expected result:
----------------
In the frames pages, the $GLOBALS and $_SERVER variables must be always defined.  Output should look like:

Array ( [0] => _GET [1] => _POST [2] => _COOKIE [3] => _FILES [4] => GLOBALS [5] => _SERVER [6] => a )

Actual result:
--------------
From time to time I do get either one of those results:

Notice: Undefined variable: GLOBALS in /var/www/.../init.php on line 10

Warning: array_keys() expects parameter 1 to be array, null given in /var/www/.../init.php on line 10
NULL 
Notice: Undefined variable: _SERVER in /var/www/.../init.php on line 11
NULL #0 require() called at [/var/www/.../right_main.php:2] Unable to detect script environment.

Or the following (less often):

Notice: Undefined variable: GLOBALS in /var/www/.../right_main.php on line 11

Warning: array_keys() expects parameter 1 to be array, null given in /var/www/.../right_main.php on line 11

Or even (not very often, but still reproductible):

array(5) { [0]=> string(4) "_GET" [1]=> string(5) "_POST" [2]=> string(7) "_COOKIE" [3]=> string(6) "_FILES" [4]=> string(7) "GLOBALS" } 
Notice: Undefined variable: _SERVER in /var/www/.../init.php on line 11
NULL #0 require() called at [/var/www/.../right_main.php:2] Unable to detect script environment.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-13 07:17 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2015-07-13 07:17 UTC] laruence@php.net
if you don't have a way to reproduce it, then we can not do much things on this..

please, try to figure out a way of how to reproduce it , thanks very much.
 [2015-07-13 18:19 UTC] phpqa at mathieuviau dot com
-Status: Feedback +Status: Open
 [2015-07-13 18:19 UTC] phpqa at mathieuviau dot com
I just did reproduce this on a brand new vagrant box, when there are enough concurrent requests to the apache server.

Simply spawn multiple processes issuing a bunch of requests to the same script URL, and some of them will consistently loose the globals.

I used 12 parallel processes, each of them issuing 5k requests in a row, and each of the process will get the issue at least once.

Btw, it still occurs with beta1.
 [2015-07-13 21:59 UTC] kalle@php.net
Just curious, does this also happen in threaded versions of PHP?
 [2015-07-14 20:01 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2015-07-16 16:33 UTC] phpqa at mathieuviau dot com
-Status: Feedback +Status: Closed
 [2015-07-16 16:33 UTC] phpqa at mathieuviau dot com
Turns out it's a wrong server config (not actually using mpm-prefork).
 [2015-07-16 16:37 UTC] cmb@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC