php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56445 APC - superglobals empty once script is cached
Submitted: 2005-07-08 19:59 UTC Modified: 2006-02-27 08:36 UTC
From: akorthaus at web dot de Assigned:
Status: Closed Package: APC (PECL)
PHP Version: 5.0 / 5.1 OS: Linux 2.4.31 (gentoo)
Private report: No CVE-ID: None
 [2005-07-08 19:59 UTC] akorthaus at web dot de
Description:
------------
I tested APC-3.0.3 with mod_php 5.0.3 and 5.1.0-beta2 (apache 1.3.33). With both versions superglobal variables in cached scripts are empty. First time I execute a script all data is there, but when it is cached from APC, $_SYSTEM, $_REQUEST... returns NULL. But in phpinfo() all data is still there.

Reproduce code:
---------------
<?php
var_dump($_SERVER);
var_dump($_ENV);
var_dump($_REQUEST);
phpinfo();
?>


Expected result:
----------------
output of $_SERVER - data, $_REQUEST - data, also if the script is cached by apc

Actual result:
--------------
NULL
NULL
NULL

PHP Version 5.1.0b2
[correct phpinfo() output...]

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-08 20:11 UTC] rasmus@php.net
Odd, I can't reproduce that here.  It probably has to do with the JIT population of the autoglobals in PHP5.  Try the following 2 tests please:

1. Add this line at the start of your test script:
   $foo = $_SERVER['SERVER_NAME'];

2. Try changing the auto_globals_jit .ini setting.  If it is on, turn it off, or vice versa.
 [2005-07-09 03:57 UTC] akorthaus at web dot de
auto_globals_jit is turned "On" by default, if I turn it "Off", the problem is solved - thanks!
 [2005-07-09 04:06 UTC] akorthaus at web dot de
(btw: the same problem occurs with 5.0.3 and probably 5.0.4 too, but auto_globals_jit has been added after those releases)
 [2005-07-09 04:10 UTC] rasmus@php.net
Ok, that gives me a place to start looking.  Odd that I couldn't reproduce it here with jit enabled.
 [2005-08-17 13:06 UTC] waffle dot iron+apc at gmail dot com
I get this as well with Apache 2.0.54, PHP 5.0.4 and APC 3.0.7.  Turning auto_globals_jit off remedies the problem.
 [2005-09-01 05:33 UTC] php at mahono dot com
I noticed the same problem:
With PHP 5.1RC1 and APC 3.0.8 and auto_globals_jit=On on my Debian (testing) system only these superglobals are defined if file runs from cache:

_POST
_GET
_COOKIE
_FILES

Setting auto_globals_jit=Off solves it - thanks a lot for that hint!
 [2005-09-07 09:39 UTC] antimon at gmail dot com
Same problem here. auto_globals_jit=Off solves.
 [2005-10-24 04:05 UTC] soporte at onfocus dot cl
Same problem here.
latest CVS APC (24/10/2005)


PHP 5.0.3 (cgi) (built: Aug 31 2005 16:08:41)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies

2.6.11.4-21.9-default #1 Fri Aug 19 11:58:59 UTC 2005 x86_64 x86_64 x86_64 GNU/Linux

gcc versi?n 3.3.5 20050117 (prerelease) (SUSE Linux)

auto_globals_jit=Off did the trick. ;)
 [2005-10-28 06:06 UTC] akorthaus at web dot de
Rasmus, I tried your other test:

<?php
$foo = $_SERVER['SERVER_NAME'];
var_dump($foo);
var_dump($_SERVER['SERVER_NAME']);
?>

But this also did not work, after 2nd request I get "NULL NULL" with auto_globals_jit=On.

I could reproduce it with several 5.1 versions: beta2, RC1, RC3, RC4-dev
 [2005-10-28 08:38 UTC] pablo at compuar dot com
Same problem here WinXP Apache 2.0.54/55/1.3.33 and php 5.1rc3/rc4-dev

When auto_globals_jit isn't set, superglobals disappear after first request.

Setting it 'off' solves the problem.
 [2005-12-01 14:05 UTC] brian at brianfrance dot com
While compiling a script zend_is_auto_global[0] is called on all variables to make sure they are JIT'ed if need be.  If we don't call compile in the case of APC, nothing gets JIT'ed.

JIT is a little hard to test as you have to make sure all the ini directives are aligned[1]:

auto_globals_jit = On
register_globals = Off
register_long_arrays = Off
register_argc_argv = Off

Just want to add this to the bug to make sure it doesn't get lost.

Brian

[0]

#0  zend_is_auto_global (name=0x36796c "_SERVER", name_len=7) at Zend/zend_compile.c:3947
#1  0x205fc81b in fetch_simple_variable_ex (result=0x9fbfcf78, varname=0x9fbfd02c, bp=1, op=83 'S') at Zend/zend_compile.c:340
#2  0x205fc976 in fetch_simple_variable (result=0x9fbfcf78, varname=0x9fbfd02c, bp=1) at Zend/zend_compile.c:383
#3  0x205f5455 in zendparse () at Zend/zend_language_parser.c:4298
#4  0x205f638f in compile_file (file_handle=0x9fbff7bc, type=2) at Zend/zend_language_scanner.c:3166
#5  0x20989ff2 in my_compile_file (h=0x9fbff7bc, type=2) at apc_main.c:260
#6  0x2060ee0c in zend_execute_scripts (type=8, retval=0x0, file_count=3) at  Zend/zend.c:1082
#7  0x205dcc33 in php_execute_script (primary_file=0x9fbff7bc) at main/main.c:1706
#8  0x206a156a in apache_php_module_main (r=0x48a07c, display_source_mode=0) at sapi/apache/sapi_apache.c:53
#9  0x206a2012 in send_php (r=0x48a07c, display_source_mode=0, filename=0x0) at sapi/apache/mod_php5.c:655
#10 0x206a205d in send_parsed_php (r=0x48a07c) at sapi/apache/mod_php5.c:670
#11 0x4b124 in ap_invoke_handler (r=0x48a07c) at http_config.c:479
#12 0x5d81c in process_request_internal (r=0x48a07c) at http_request.c:1374
#13 0x5d877 in ap_process_request (r=0x48a07c) at http_request.c:1390
#14 0x55c2a in child_main (child_num_arg=0) at http_main.c:5399
#15 0x55e74 in make_child (s=0x9ccc8, slot=0, now=1133370025) at http_main.c:5581
#16 0x55f99 in startup_children (number_to_start=32) at http_main.c:5679
#17 0x56505 in standalone_main (argc=2, argv=0x9fbffaf4) at http_main.c:6080
#18 0x56c8c in main (argc=2, argv=0x9fbffaf4) at http_main.c:6461

[1]

php_variables.c:666         zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays) && !PG(register_argc_argv));
 [2005-12-14 11:07 UTC] jplock at yahoo dot com
This issue also occurs on Solaris 8, 9, and 10 with PHP 5.1.1 and Apache 1.3.34. Turning off auto_globals_jit seemed to work for a little while, but then the issue returned.
 [2005-12-18 06:43 UTC] spam at dragy dot de
Same problem with Apache 2.2, PHP 5.1.1 and APC 3.0.8 on Windows XP 32bit (Athlon 64).

First hit fully populated, then most disappear.
 [2006-02-23 22:15 UTC] rasmus@php.net
This should finally be fixed.  Please try the current CVS version.
 [2006-02-24 02:55 UTC] akorthaus at web dot de
The CVS version definitly works now (using PHP 5.1.2, Apache 2.0.55), 3.0.8 still failed. Thanks a lot for fixing the issue!

So it's a good idea to switch "auto_globals_jit" on now?
 [2006-02-24 03:19 UTC] rasmus@php.net
Yes
 [2006-02-24 03:25 UTC] akorthaus at web dot de
The CVS version also resolves another bug (which I have not reported yet because I could not reproduce it with a simple script). APC <=3.0.8 sometimes returned the output for the wrong script, I requested a script, which was not cached, and I only saw the output of another script which has been cached before. This had nothing to do with auto_globals_jit=On.

Anyway - this issue is solved with latest CVS version too, so I'm looking forward to a hopefully soon release ;-)

APC 3.0.9-dev is first version, which seems to work with all my PHP applications without any problems!
 [2006-02-27 04:31 UTC] stas_t at mail dot com
sorry guys but the bug still persist in windows version (Apache/2.0.55 (Win32) PHP/5.1.2 apc/3.0.9-dev)
 [2006-02-27 04:45 UTC] rasmus@php.net
I bet you are not running the latest code then.

I don't do Windows, so I can't help you.
 [2006-02-27 08:36 UTC] akorthaus at web dot de
Try the latest snapshot, if phpinfo() shows an APC revision >= 3.80, the patch should be included.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Nov 17 10:01:32 2019 UTC