Category
php-in-php · stdlib · bootstrap
Problem
VM file reads (file_get_contents, readfile, zip extract, compiler include I/O) funnel through VmFsReadNative — libc open(2)/read(2) via FFI (ext/standard/VmFsReadNative.php). When PHP_COMPILER_DISABLE_FFI=1 (bootstrap/self-host probes), file_get_contents() returns false for readable paths — blocking inventory, capability checks, and M5 fast path without host Zend.
Pure PHP can read regular files via fopen/fread stream wrappers compiled through this pipeline (or thin read(2) syscall stub only when ABI-unavoidable).
php-src reference
Repro
PHP_COMPILER_DISABLE_FFI=1 php bin/vm.php -r '
echo file_get_contents(__FILE__) === false ? "FAIL\n" : "ok\n";
'
Observed: FAIL (FFI path returns false from VmFsReadNative::read()).
Expected: file contents string (match Zend on same path).
Scope
| Path |
Work |
ext/standard/VmFsReadNative.php |
Add VmFsReadPure fallback (PHP streams / compiled fread path) |
ext/standard/VmFsWriteNative.php |
Pair write path if needed for symmetry |
| Callers |
file_get_contents.php, VmZipArchive.php, VmString::realpath helpers |
| Tests |
test/unit/ext/standard/VmFsReadPureTest.php + repro under PHP_COMPILER_DISABLE_FFI=1 |
Shrink C/FFI: delete or gate libc read FFI once PHP path is proven; document lines removed.
Done when
Links
Category
php-in-php·stdlib· bootstrapProblem
VM file reads (
file_get_contents,readfile, zip extract, compilerincludeI/O) funnel throughVmFsReadNative— libcopen(2)/read(2)via FFI (ext/standard/VmFsReadNative.php). WhenPHP_COMPILER_DISABLE_FFI=1(bootstrap/self-host probes),file_get_contents()returnsfalsefor readable paths — blocking inventory, capability checks, and M5 fast path without host Zend.Pure PHP can read regular files via
fopen/freadstream wrappers compiled through this pipeline (or thinread(2)syscall stub only when ABI-unavoidable).php-src reference
ext/standard/file.c—php_stream_copy_to_mem,file_get_contentsmain/streams/streams.c— stream layer (reference semantics)Repro
Observed:
FAIL(FFI path returnsfalsefromVmFsReadNative::read()).Expected: file contents string (match Zend on same path).
Scope
ext/standard/VmFsReadNative.phpVmFsReadPurefallback (PHP streams / compiled fread path)ext/standard/VmFsWriteNative.phpfile_get_contents.php,VmZipArchive.php,VmString::realpathhelperstest/unit/ext/standard/VmFsReadPureTest.php+ repro underPHP_COMPILER_DISABLE_FFI=1Shrink C/FFI: delete or gate libc read FFI once PHP path is proven; document lines removed.
Done when
PHP_COMPILER_DISABLE_FFI=1 php bin/vm.phprepro reads__FILE__successfullyVmFsReadNative.phpLinks