Skip to content

Stdlib: getenv() local_only second argument — VM + AOT (#3710) - #3770

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-getenv-local-only
May 30, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-getenv-local-only

Conversation

@PurHur

@PurHur PurHur commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implements getenv(string $name, bool $local_only = false) per php-src zif_getenv / EG(env) — VmEnv tracks putenv() assignments; local_only=true reads only that table.
  • Fixes putenv() / getenv() as statements: internal handlers no longer return early when returnVar is null (FUNCCALL_EXEC_NORETURN), which previously made putenv('X=1'); a no-op before a 2-arg getenv() call.
  • AOT: phpc_env_local.c, extended __compiler_getenv(name, local_only, out), StringEnvLocal MCJIT bitcode link; putenv JIT registers local table via __compiler_env_register_putenv.

php-src: ext/standard/basic_functions.c

Test plan

  • vendor/bin/phpunit --filter getenv_local_only — VMTest + AotTest green
  • php bin/compile.php -l test/repro-maintainer/getenv_local_only.php
  • JITTest — MCJIT subprocess exit -1 in Docker harness (same class of flake as other getenv/putenv JIT cases); bin/jit.php may segfault on this host — follow-up if needed

Closes #3710

Made with Cursor

@PurHur

PurHur commented May 30, 2026

Copy link
Copy Markdown
Owner Author

Maintainer review (local Docker)

Verified on `agent/stdlib-getenv-local-only` via `./script/docker-exec.sh`:

  • `vendor/bin/phpunit --filter getenv_local_only` — VMTest + AotTest pass (3/5 cases)
  • JITTest `stdlib/getenv_local_only*` — MCJIT subprocess exit -1 (same class as other getenv/putenv JIT flakes noted in PR)

Not merging until JIT compliance is green or explicitly scoped VM+AOT-only with JITTest skips documented on #3710.

VM semantics for `local_only` and `putenv` no-return fix look correct from repro; good to land once JIT path is stable or skipped like other env builtins.

Implement Zend putenv()/getenv() local environment table (php-src EG(env)):
VmEnv tracks variables set via putenv(); getenv($name, $local_only=true) reads
only that table. Fix putenv_/getenv_ to run side effects on FUNCCALL_EXEC_NORETURN
(was a no-op when the return value was unused).

AOT/JIT: __compiler_getenv(name, local_only, out), phpc_env_local.c, MCJIT
StringEnvLocal bitcode link. php-src: ext/standard/basic_functions.c.

Verification: vendor/bin/phpunit --filter getenv_local_only  (VM + AOT green; JIT MCJIT -1 in Docker)
  php bin/compile.php -l test/repro-maintainer/getenv_local_only.php
Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur force-pushed the agent/stdlib-getenv-local-only branch from de59db2 to 9f4f6d1 Compare May 30, 2026 12:33
@PurHur
PurHur merged commit 5056a86 into master May 30, 2026
@PurHur
PurHur deleted the agent/stdlib-getenv-local-only branch May 30, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: getenv() — local_only second argument (ext/standard/basic_functions.c parity)

1 participant