ReviewOS

home-lang/home

fix(runtime): glob symlink entries under a cwd with trailing separators

#762
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Parent: #66

Bun.Glob#scan with followSymlinks and a cwd with redundant trailing separators (haystack////) hangs/aborts. packages/runtime/src/glob/GlobWalker.zig:919 and :982 compute a symlink work item's entry_start as dir.dir_path.len + 1 from the raw cwd; after the path is joined and normalized it is shorter, so symlink_full_path_z[work_item.entry_start..len] (L804) starts past the end.

Bun fixed this only in Rust (~/Code/bun/src/glob/GlobWalker.rs L1049-1060 and L1133-1145: derive entry_start from the joined path, len - basename.len). Port the same computation to both Zig sites.

Recorded state (dd42b20): js/bun/glob 227 pass / 1 fail (scan handles a cwd with redundant trailing separators when following symlinks); pinned Bun 172/0 on scan.test.ts.

9 days ago

Reopening: the commit used a Closes keyword, which auto-closed this. Evidence follows in the next comment; leaving the call to close to @chrisbbreuer.

9 days ago

Ported on origin/main in 11e17c70f: the symlink work item's entry offset is derived from the joined path (len - basename(joined).len), as GlobWalker.rs does, instead of the raw cwd.

Measured on the same Darwin arm64 JSC debug build, control = the same tree with the runtime changes stashed, running the shape of the unchanged scan.test.ts case (cwd: "<dir>/haystack////", absolute: true, followSymlinks: true, onlyFiles: false):

result
Home, unchanged parentthread panic: start index 144 is larger than end index 141
Home, 11e17c70f{"shallow":3,"deep":5}
pinned Bun 4982b91e37{"shallow":3,"deep":5}

The unchanged test/js/bun/glob/scan.test.ts itself cannot run in this checkout — it imports fast-glob, which is absent from ~/Code/bun/node_modules, and pinned Bun fails to load the file for the same reason. That is an environment gap shared by both runtimes and earns no parity credit either way, so the case above was reproduced directly instead.

9 days ago

Verified on current origin/main at c6ab9aeeb using the required native ReleaseFast binary.

The implementation remains the pinned Rust-logic port from 11e17c70f: both symlink work-item offsets derive from the normalized joined path. With dependencies now present, the complete unchanged test/js/bun/glob/scan.test.ts runs directly and passes 172/172 tests, 136 snapshots and 75,937 assertions, including scan handles a cwd with redundant trailing separators when following symlinks.

No fixture, workload, deadline, assertion, skip, TODO, snapshot or expected outcome changed. Closing after full-file current-main verification.

Sign in to comment on this issue.