Skip to content

Stdlib: realpath('') empty path — returns false not cwd (ext/standard/basic_functions.c) #10257

Description

@PurHur

Category

stdlib · php-src-strict

Problem

realpath('') with an empty string path must resolve to the current working directory (same as realpath('.')). This compiler returns false, breaking path normalization in self-host and app code that passes user input through realpath() without an explicit . fallback.

php-src reference

Repro (verified 2026-06-20)

test/repro/maintainer_gap_realpath_empty.php:

<?php
var_export(realpath(''));
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_realpath_empty.php
php bin/vm.php test/repro/maintainer_gap_realpath_empty.php
'
Runtime Result
Zend PHP 8.2+ '/path/to/cwd' (non-empty string)
php bin/vm.php false ❌

Scope (PHP-in-PHP first)

Layer Path
VM builtin ext/standard/realpath.php — treat '' like '.' before stat/canonicalize
JIT/AOT mirror VM if realpath is lowered inline
Tests test/compliance/cases/stdlib/realpath_empty_string.phpt

No new C runtime.

Done when

  • Repro prints cwd string on VM (matches Zend in same directory)
  • realpath('.') unchanged
  • Invalid/nonexistent paths still false per Zend
  • Targeted compliance guard green

Related

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions