Skip to content

Language: $ref = &$GLOBALS must compile-time fatal — VM executes (Zend/zend_compile.c) #15627

Description

@PurHur

Category

language · php-src-strict

Problem

Zend rejects acquiring a reference to the superglobal $GLOBALS at compile time. This compiler accepts the assignment and runs the script.

Snippet Zend 8.2+ VM (2026-07-03)
$ref = &$GLOBALS; Fatal error: Cannot acquire reference to $GLOBALS (compile) prints fail: acquired GLOBALS reference, exit 0

php-src reference

PHP implementation target

  • lib/ compile path for assign_ref when RHS is $GLOBALS — emit Zend-equivalent compile-time fatal
  • No new C runtime branches; guard in PHP lowering only

Repro

test/repro/maintainer_gap_globals_acquire_reference.php

./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_globals_acquire_reference.php'   # exit 255
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_globals_acquire_reference.php'   # exit 0 (wrong)

Done when

  • VM/JIT/AOT reject at compile time with Zend-equivalent fatal text
  • Compliance .phpt under test/compliance/cases/language/
  • php-src-strict; no php-compiler-strict shortcut

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions