Skip to content

Stdlib: putenv() invalid assignment syntax — returns false not ValueError (ext/standard/basic_functions.c) #10335

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

putenv() with a malformed assignment string (no = name, e.g. "=x") must throw ValueError: putenv(): Argument #1 ($assignment) must have a valid syntax. VM returns false silently.

php-src reference

Repro (failure today)

test/repro/maintainer_gap_putenv_invalid_syntax.php:

<?php
declare(strict_types=1);

var_export(putenv('=invalid'));
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_putenv_invalid_syntax.php 2>&1 | head -2
php bin/vm.php test/repro/maintainer_gap_putenv_invalid_syntax.php 2>&1
'
Runtime Result
Zend PHP 8.2 ValueError (valid syntax required)
VM false ❌

Scope (this repo)

Path Work
ext/standard/putenv.php Validate name=value / name forms; throw ValueError on invalid syntax
ext/standard/getenv.php Cross-check paired semantics (#4177 scalar coercion)
ext/standard/JitPutenv.php Mirror at JIT when present
Tests test/compliance/cases/stdlib/putenv_invalid_syntax.phpt

PHP-in-PHP: validation in ext/standard/; reuse shared builtin arg/error helpers.

Done when

  • Repro throws ValueError on VM
  • Valid putenv('KEY=value') / unset forms unchanged
  • ./script/ci-fast.sh --filter putenv_invalid_syntax green

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 20, 2026
  2. PurHur commented on Jun 20, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  3. PurHur commented on Jun 20, 2026

    @PurHur
    OwnerAuthor

    Merged via #10353.

    Verification

    • VM: putenv('=invalid') throws ValueError: putenv(): Argument #1 ($assignment) must have a valid syntax
    • JIT: same via putenv_invalid_syntax_jit.phpt
    • Valid KEY=value / unset forms unchanged
    • ./vendor/bin/phpunit --filter "GetenvJitRuntimeShrinkTest|putenv_invalid_syntax" --exclude-group aot → OK (10 tests)
    • php bin/compile.php -l test/repro/maintainer_gap_putenv_invalid_syntax.php → OK (AOT lowering guard linked)

    Implementation: VmEnv::assertValidPutenvSyntax() (php-src zif_putenv), mirrored in GetenvJitHelper + JitEnv::emitPutenvSyntaxGuard() for JIT/AOT.

    Note: full native link/execute for putenv() remains blocked by a pre-existing standalone IR verify failure on master; AOT fixture deferred until that regression is fixed.

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-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions