php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65405 APC fails to propagate $GLOBALS when auto_globals_jit=Off
Submitted: 2013-08-06 15:59 UTC Modified: 2013-09-12 05:39 UTC
From: tyrael@php.net Assigned: laruence (profile)
Status: Closed Package: APC (PECL)
PHP Version: 5.4.17 OS:
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: tyrael@php.net
New email:
PHP Version: OS:

 

 [2013-08-06 15:59 UTC] tyrael@php.net
Description:
------------
I bumped into the issue that with php5.4, apc enabled and having 
auto_globals_jit=Off the second request (after it is cached by apc) can be missing 
variables from the $GLOBALS superglobal. 

See the attached file for a reproducible testcase(it is weird, but without that 
sleep call the test sporadically passes), and I also managed to eliminate the bug 
via removing the two PG(auto_globals_jit) checks from apc_compile.c, but I'm not 
sure that it is the best solution(altough it didn't break any tests).
Another thing worth nothing that it seems that the same thing was changed/fixed in  
opcache/ZendOptimizer+:
http://git.php.net/?p=php-
src.git;a=commitdiff;h=0ab356c8e59018fbedd0fd6ddfd6a82f4558c9a9

Test script:
---------------
--TEST--
APC fails to propagate $GLOBALS when auto_globals_jit=Off
--SKIPIF--
<?php
    require_once(dirname(__FILE__) . '/skipif.inc');
    if (PHP_MAJOR_VERSION < 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4)) {
		die('skip PHP 5.4+ only');
	}
--FILE--
<?php
include "server_test.inc";

$tmp = 'bug_auto_globals_jit_off.tmp.php';
$tmp_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . $tmp;

$file =
<<<FL
<?php
	\$foo = 'bar';
	function foo () {
		global \$foo;
		print_r("\$foo\\n");
		print_r("\${GLOBALS['foo']}\\n");
		\$foo = 'baz';
		print_r("\$foo\\n");
		print_r("\${GLOBALS['foo']}\\n");
	}
	print_r("\${GLOBALS['foo']}\\n");
	foo();
	print_r("\${GLOBALS['foo']}\\n");
FL;

file_put_contents($tmp_file, $file);

$args = array(
	'apc.enabled=1',
	'apc.cache_by_default=1',
	'apc.enable_cli=1',
	'auto_globals_jit=Off',
	'display_errors=On',
	'error_reporting=-1',
	'html_errors=Off',
);

$num_servers = 1;

server_start('', $args, true);

sleep(5);

print_r("first request\n");
run_test_simple('/'.$tmp);
print_r("second request\n");
run_test_simple('/'.$tmp);

print_r("done");
?>
--CLEAN--
<?php
unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . "bug_auto_globals_jit_off.tmp.php");
?>
--EXPECT--
first request
bar
bar
bar
baz
baz
baz
second request
bar
bar
bar
baz
baz
baz
done

Expected result:
----------------
bar
bar
bar
baz
baz
baz
bar
bar
bar
baz
baz
baz
done

Actual result:
--------------
first request
bar
bar
bar
baz
baz
baz
second request

Notice: Undefined variable: GLOBALS in /www/checkouts/php-
apc/trunk/tests/bug_auto_globals_jit_off.tmp.php on line 11

bar

Notice: Undefined variable: GLOBALS in /www/checkouts/php-
apc/trunk/tests/bug_auto_globals_jit_off.tmp.php on line 6

baz

Notice: Undefined variable: GLOBALS in /www/checkouts/php-
apc/trunk/tests/bug_auto_globals_jit_off.tmp.php on line 9


Notice: Undefined variable: GLOBALS in /www/checkouts/php-
apc/trunk/tests/bug_auto_globals_jit_off.tmp.php on line 13

done

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-03 02:29 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2013-09-12 04:08 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=331353
Log: Fixed bug #65405 (APC fails to propagate $GLOBALS when auto_globals_jit=Off)
 [2013-09-12 05:39 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2013-09-12 05:39 UTC] laruence@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

fixed in http://svn.php.net/viewvc?view=revision&revision=331353
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 09:01:34 2025 UTC