Skip to content

Regression: var_export() array keys with NUL bytes — stripped labels not php-src concatenation (ext/standard/var.c) #13875

Closed

Description

@PurHur

Summary

var_export() on arrays whose keys contain NUL bytes (e.g. output of get_mangled_object_vars()) must emit php-src’s concatenation form for those keys. This compiler prints stripped key labels (NUL bytes omitted from the exported source), breaking round-trip/debug parity.

php-src reference: ext/standard/var.c — php_var_export() / hash key export with \0 bytes ('' . "\0" . '*' . "\0" . 'w' style).

PHP implementation target: ext/standard/VmVarExport.php (VM SSOT) + JIT route through shared helper (#9189); no new C runtime logic.

Repro (verified 2026-06-30)

test/repro/maintainer_gap_var_export_mangled_array_keys.php

<?php
declare(strict_types=1);
class C { protected $w = 1; private $p = 2; }
$exported = var_export(get_mangled_object_vars(new C()), true);
if (!str_contains($exported, '\0')) { exit(1); }
echo "ok\n";
./script/docker-exec.sh -- php test/repro/maintainer_gap_var_export_mangled_array_keys.php   # Zend: ok
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_var_export_mangled_array_keys.php  # VM: fail
Check Zend VM
Protected key export '' . "\0" . '*' . "\0" . 'w' => 1 "\0*\0w" => 1 (no \0 escape sequence in source)
Repro exit 0 1

Note: underlying array keys from get_mangled_object_vars() are correct (NUL bytes present); only export formatting diverges.

Done when (php-src-strict)

  • var_export() emits php-src concatenation for keys containing \0 (VM)
  • JIT/AOT match VM when var_export is lowered
  • Compliance guard under test/compliance/ or committed test/repro/
  • PR cites var.c and notes any LLVM shrink if JIT path touched

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 30, 2026
  2. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #13876, #13875)

  3. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    Merged via #13878. VM/JIT/AOT lint green; var_export output now matches Zend concatenation form for NUL-byte mangled keys.

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