Skip to content

Sparse overlay leaks host lookup errno as a worker crash #4165

Description

@chubes4

Problem

Filesystem probes against an invalid host path, such as a filename longer than the platform component limit, crash a sparse-overlay fresh worker with a raw Node exception:

ENAMETOOLONG: name too long, lstat ...
    at sourcePath
    at overlay.node_ops.lookup
    at FS.lookupNode
    at faccessat

PHP should receive normal filesystem errno semantics so functions such as file_exists() can return false and callers can handle the path. Standard NODEFS translates host exceptions through NODEFS.tryFSOperation().

Root cause

createOverlayNodeFsMountHandler().node_ops.lookup() calls sourcePath() and NODEFS.getMode() outside NODEFS.tryFSOperation(). Host errors other than the helper's special-cased ENOENT escape JavaScript and terminate the workload.

Expected behavior

Run the complete overlay lookup inside NODEFS.tryFSOperation() so native ENAMETOOLONG, EACCES, and related lookup errors become Emscripten/PHP filesystem errors.

Reproduction

Inside a sparse overlay mount:

echo file_exists( "/overlay/" . str_repeat( "x", 300 ) ) ? "exists" : "missing";

Expected: missing.
Observed before fix: raw Node ENAMETOOLONG worker crash.

Downstream evidence: the WordPress core wp_tempnam() length tests in the other PHPUnit suite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions