php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76284 auto_globals_jit doesn't detect all types of superglobal use
Submitted: 2018-04-28 22:38 UTC Modified: 2018-06-24 09:18 UTC
From: jocrutrisi at ibsats dot com Assigned:
Status: Re-Opened Package: Scripting Engine problem
PHP Version: 7.2.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jocrutrisi at ibsats dot com
New email:
PHP Version: OS:

 

 [2018-04-28 22:38 UTC] jocrutrisi at ibsats dot com
Description:
------------
I was unexpectedly bit by "$_ENV undefined" notice when using auto_globals_jit.

Apparently PHP is very specific about what is considered a superglobal use and what isn't.

See examples below.

Test script:
---------------
// This is considered $_ENV use.
$foo = $_ENV['foo'];

// This is considered $_ENV use.
foreach ($_ENV as $k => $v);

// BUG: This is NOT considered $_ENV use (so I get a notice here that $_ENV is undefined)
$foo = $_ENV;

// BUG: Another example of the same problem (I get a notice $_ENV is undefined)
function foo() {
    return ['env' => $_ENV];
}
foo();

Expected result:
----------------
I expect JIT should work transparently. Any mention of $_ENV must cause $_ENV to get defined as if it always was.

The exceptions are rather odd, it's unclear why detection of use is not fully comprehensive.

Actual result:
--------------
Notice of undefined $_ENV.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-29 04:59 UTC] requinix@php.net
-Status: Open +Status: Feedback -Package: PHP options/info functions +Package: Scripting Engine problem
 [2018-04-29 04:59 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

Works for me, and that exact code you posted won't do the job anyways. The repro script has to be precise, not some summarized version of your tests.
 [2018-05-03 20:04 UTC] jocrutrisi at ibsats dot com
Hello, the samples I posted above are sufficient to reproduce the problems for me.

I just enable auto_globals_jit, make sure error reporting (and optionally error display) are on, and then:

<?php
$foo = $_ENV;
?>

This will produce:

<br />
<b>Notice</b>:  Undefined variable: _ENV in <b>[...][...]</b> on line <b>2</b><br />

If you can't reproduce this, we might need to narrow down the situation. I only have access to 7.2.4 right now, BTW, but this wasn't available in the drop-down with versions, so I had to specify 7.2.5, seeing as the list of fixes contains nothing relevant.
 [2018-06-24 04:25 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2018-06-24 09:18 UTC] nikic@php.net
-Status: No Feedback +Status: Re-Opened
 [2018-06-24 09:18 UTC] nikic@php.net
Just tried this as well. I also can't reproduce under both cli and cli-server.

Can you please check if this occurs when running with -n? (I.e. php -n -d error_reporting=E_ALL -d auto_globals_jit=1)
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 08:01:24 2019 UTC