Skip to content

Regression: get_defined_constants(true) spurious user bucket — SNMP_* (re-#22337, Zend/zend_builtin_functions.c) #22858

Description

@PurHur

Category

Stdlib · php-src-strict · constant categorization (re-#22337 / #19113 / #18303)

Problem

With no user define(), Zend’s get_defined_constants(true) has no user bucket when ext/snmp is not loaded. VM still emits a user bucket (~24 names) whose keys are almost entirely SNMP_* constants. Those names are also defined() / extension_loaded('snmp') / class_exists('SNMP') true on VM while Zend (this host, no snmp) reports all false and has no snmp category bucket either.

#22337 closed the FTP/mysqli mis-bucket case; SNMP is the same class of leak.

Probed 2026-07-24 (host PHP 8.2.32 without snmp vs php bin/vm.php).

Repro Zend 8.2+ (no snmp) VM (2026-07-24)
isset(get_defined_constants(true)['user']) before any define() false true (user=24)
user keys starting with SNMP_ n/a 13
defined('SNMP_VERSION_1') false true
extension_loaded('snmp') false true
class_exists('SNMP', false) false true
isset(...['snmp']) false false (constants dumped into user instead)

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'php test/repro/get_defined_constants_snmp_user_bucket.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/get_defined_constants_snmp_user_bucket.php'

Done when

  • Before any define(), get_defined_constants(true) has no user bucket on the default/reference profile when snmp is not loaded (Zend match)
  • SNMP_* are not defined() and extension_loaded('snmp') / class_exists('SNMP') are false in that configuration
  • When snmp is intentionally enabled, constants appear under snmp (not user)
  • Compliance .phpt guard under test/compliance/cases/
  • php-src-strict; no php-compiler-strict shortcut

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions