Skip to content

deps: update libarchive to v3.8.5 - #11

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
deps/update-libarchive-5
Open

github-actions[bot] wants to merge 1 commit into
mainfrom
deps/update-libarchive-5

Conversation

@github-actions

Copy link
Copy Markdown

What does this PR do?

Updates libarchive to version v3.8.5

Compare: libarchive/libarchive@9525f90...dd897a7

Auto-updated by this workflow

crishoj pushed a commit that referenced this pull request Jul 29, 2026
…ry rewrite (oven-sh#34271)

`test/js/bun/util/filesystem_router.test.ts` went red on alpine x64 in
build [73276](https://buildkite.com/bun/bun/builds/73276): the `reload()
while Bun.build() resolves the same directory` subprocess segfaulted in
`bust_dir_cache_recursive`, inlined from `NonNull::new`.

## Cause

`RealFS::entries_at` (`src/resolver/lib.rs`) replaces a cached
`DirEntry` in place when the caller's resolver generation is newer than
the cached listing's. The replacement at `*e_ptr = new_entry` drops the
old `DirEntry`, which drops its `data: StringHashMap<*mut Entry>` and
frees the hashmap's bucket allocation. The function's comment says
`entries_mutex held by caller`, but that is only true on one of the five
paths that reach it: `dir_info_uncached`, when entered from
`dir_info_cached_miss`. The other callers (`finalize_result`,
`handle_esm_resolution`, `load_index_with_extension`,
`Transpiler::run_env_loader`) all reach `entries_at` after
`dir_info_cached_maybe_log` has already returned and released both
`RESOLVER_MUTEX` and `entries_mutex`.

`FileSystemRouter::reload()` and `RouteLoader::load` iterate the same
`DirEntry.data` map under `entries_mutex` (the snapshot pattern oven-sh#33056
introduced for exactly this kind of concurrent rewrite). With
`entries_at`'s rewrite unsynchronized, a `Bun.build()` on the bundler
thread can drop the map while `reload()` on the JS thread is
mid-iteration.

The generation mismatch is what makes `entries_at` enter its rewrite
branch, so the window only opens once the bundle thread has processed at
least one batch (it bumps its own generation after every queue drain);
every subsequent `Bun.build()` then re-reads any directory that
`reload()` just refreshed to generation 0.

ASAN catches it as a heap-use-after-free with the two sides of the race
laid out exactly:

```
READ of size 16 (thread T0):
  #6 HashMap::values
  #7 StringHashMap<*mut Entry>::values                       src/collections/array_hash_map.rs:1864
  #8 FileSystemRouter::bust_dir_cache_recursive              src/runtime/api/filesystem_router.rs:395
  #9 FileSystemRouter::bust_dir_cache                        src/runtime/api/filesystem_router.rs:451
  #10 FileSystemRouter::reload                               src/runtime/api/filesystem_router.rs:476

freed by thread T11 (Bundler):
  #11 drop_in_place<bun_resolver::fs_full::DirEntry>
  #12 bun_resolver::fs::RealFS::entries_at                   src/resolver/lib.rs:1639
  #13 DirInfo::get_entries_ref                               src/resolver/dir_info.rs:266
  #14 Resolver::finalize_result                              src/resolver/resolver.rs:1714
  #15 Resolver::resolve_and_auto_install                     src/resolver/resolver.rs:1485
  ...
  #23 BundleThread::generate_in_new_thread                   src/bundler/BundleThread.rs:276

previously allocated by thread T0:
  #17 HashMap::reserve
  #18 Resolver::dir_info_cached_miss                         src/resolver/resolver.rs:4591
  #19 Resolver::dir_info_cached_maybe_log                    src/resolver/resolver.rs:4201
  #20 Resolver::read_dir_info                                src/resolver/resolver.rs:4118
  #21 FileSystemRouter::reload                               src/runtime/api/filesystem_router.rs:492
```

(The use side is sometimes `RouteLoader::load` at
`src/router/lib.rs:816` instead; same map, same lock.)

This has been the shape of `entries_at` since the Rust port; oven-sh#33056
narrowed the race by snapshotting under the lock but assumed the rewrite
side already held it.

## Fix

`entries_at` now takes `entries_mutex` itself, matching
`read_directory_with_iterator` which already does. The one call path
that reaches it with the lock already held (`dir_info_cached_miss` ->
`dir_info_uncached` -> `parent_.get_entries_ref`) routes through a new
`entries_at_locked` / `get_entries_ref_locked` pair so the non-recursive
mutex is not re-entered. That path is the only one that passes a
non-`None` parent to `dir_info_uncached`; the other caller
(`dir_info_for_resolution`) passes `None`, so the parent branch
containing the accessor never runs there.

## Test

The existing concurrency test now awaits one `Bun.build()` first, so the
bundle thread's generation is already past zero when the concurrent
rounds start, and then runs forty reload/build rounds instead of one.
That is the shape that reaches the stale-generation rewrite at all; the
original single-round fixture usually completes with every build still
on generation 0.

The race is scheduling-dependent. Pinning the fixture to a single core
reproduces the ASAN use-after-free on roughly 3 in 10 runs against an
unpatched debug build and 0 in 15 with this change; with all 16 cores
available the unpatched build reproduces at roughly 1 in 30. The
assertions are otherwise the same as before, so the test continues to
cover the behavior oven-sh#33056 added.

Also ran the full `filesystem_router.test.ts`,
`test/bundler/bun-build-api.test.ts` (including the thousands-of-builds
test that exercises the generation path heavily),
`test/js/bun/resolve/resolve.test.ts`, `test/cli/hot/hot.test.ts`,
`test/cli/watch/watch.test.ts`, `test/bake/framework-router.test.ts`,
and `bun run rust:check-all` (10/10 targets).

<!-- robobun:evidence:begin -->

---

**no test proof** · iteration 0 · Platform-specific test(s) that do not
run on this machine. Deferring to CI, which covers all platforms:
test/js/bun/util/filesystem_router.test.ts

<!-- robobun:evidence:end -->
crishoj pushed a commit that referenced this pull request Jul 29, 2026
…ven-sh#35209)

Companion to oven-sh/libuv#11 (merged as `2881ce5` on the `bun` branch).

## What changes for Bun

oven-sh/libuv#11 fixes seven Windows error-translation/propagation bugs
found by audit, scoped to those reachable from Bun's own code. Full
breakdown is in [this comment on the libuv
PR](oven-sh/libuv#11 (comment)).

The one user-visible change: on Windows, an async write to a pipe whose
read end has closed now delivers `{code: "EPIPE"}` to the write callback
instead of `{code: "EOF"}`. Before the fix, `uv__process_pipe_write_req`
used the read-side translator, which maps `ERROR_BROKEN_PIPE` /
`ERROR_NO_DATA` to `UV_EOF` / `UV_EAGAIN`; the write-side translator
maps both to `UV_EPIPE`, matching Node and the synchronous `uv_write()`
path.

This also fixes `shell::IOWriter::on_error`'s broken-pipe detection
(`src/runtime/shell/IOWriter.rs:867`), which keys on `E::PIPE` and so
was not firing when the failure arrived via the async write completion.

## Changes

- `scripts/build/deps/libuv.ts`: bump `LIBUV_COMMIT` to `2881ce5` (the
#11 merge) and add #11 to the provenance comment.
- `test/js/bun/spawn/spawn.test.ts`: new test `stdin.end() rejects with
EPIPE when the child exits before consuming the write`. The child reads
one byte and exits, leaving 16MB queued on the parent's stdin (large
enough to exceed macOS socket autotuning and the 64KB Windows named-pipe
buffer), so `end()` is still draining when the read end closes. Verified
fail-before on Windows (`caught.code === "EOF"` with the current
release) and pass on Linux/macOS.

The existing `child_process` `stdin write failure (EPIPE)` test is left
skipped on Windows: its child does `fs.closeSync(0)`, but libuv's
`fs__close` on Windows is a no-op for fd ≤ 2 (`src/win/fs.c:690`), so
the pipe never breaks and the test hangs. That skip is unrelated to #11.

## Not changed (reachable from Bun, strict improvement, no code change
needed)

- `uv_pipe()` (used by `spawn/process.rs:2000`, `sys/lib.rs:4393`,
`install/security_scanner.rs:1129`): previously returned a raw positive
Win32 error on failure; Bun's `ReturnCode` predicate is `< 0`, so that
leaked through as success with garbage fds. Now returns a negative
`UV_E*`. Bun-side check was already correct.
- `uv_fs_realpath` / `uv_fs_readlink` (used by `fs.realpath*`,
`fs.readlink*`, `fs.cp`, `fs.watch`): OOM during UTF-16 conversion now
reports `ENOMEM` instead of success-with-null or a stale error.
- `fs__filemap_ex_filter` (`UV_FS_O_FILEMAP`, exposed via
`fs.constants`): in-page errors now surface the real disk error instead
of `UNKNOWN`.
- `uv__tty_move_caret` (legacy console ANSI emulation): missing `return
-1` added; bypassed on Windows 10+ where Bun enables VT mode at startup.

<!-- robobun:evidence:begin -->

---

**no test proof** · iteration 3 · Platform-specific test-only change;
deferring to CI.

<!-- robobun:evidence:end -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant