Fix Android/FreeBSD runtime issues found by running the test suite - #38237
Closed
dylan-conway wants to merge 2 commits into
Closed
Fix Android/FreeBSD runtime issues found by running the test suite#38237dylan-conway wants to merge 2 commits into
dylan-conway wants to merge 2 commits into
Conversation
…suite - --compile on Android: standalone executables are PIE there, so the embedded module graph's link-time vaddr must be adjusted by the load bias before dereferencing (every compiled binary segfaulted at startup). - --compile on FreeBSD/UFS: carry the temp path out of inject() instead of reverse-mapping fd -> path, which came back empty via F_KINFO and made the final rename fail with ENOENT. - FreeBSD: drop -z stack-size from the link. FreeBSD's exec uses PT_GNU_STACK's size as the main-thread stack reservation while libthr reports RLIMIT_STACK, so stack-overflow guards never fired and deep recursion died with SIGILL instead of throwing RangeError. - FreeBSD: call __xuname(256, ...) for uname; the exported `uname` symbol fills 32-byte fields, leaving utsname.release empty. - FreeBSD kqueue: ignore EV_ERROR/ENOENT|EBADF receipts for a Cancel of an already-fired oneshot knote instead of surfacing them as read errors (broke reading FIFOs/pipes via Bun.file()). - FreeBSD: enable Bun.Terminal / PTY by dlopen'ing openpty from libutil. - Test runner + harness: recognize freebsd and android hosts.
Collaborator
|
Updated 1:55 PM PT - Aug 13th, 2026
@dylan-conway, your commit d5249e9 is building: |
The receive side passed msg_controllen = CMSG_LEN(sizeof(int)), which is 4 bytes short of the aligned size on FreeBSD (12-byte cmsghdr, 8-byte alignment: 20 vs 24). FreeBSD then sets MSG_CTRUNC and discards the descriptor, so every handle sent over IPC (cluster, child_process.fork with a server/socket) was lost and the receiver hung. Linux tolerates the short buffer and on macOS the two sizes are equal, which is why this never showed up before. Also gate the FORCE_WAITER_THREAD self-test in spawn.test.ts on Linux: the waiter thread is the pidfd-less Linux fallback and its non-Linux loop has no wakeup, so running it on FreeBSD hangs.
Contributor
|
Found 2 issues this PR may fix:
🤖 Generated with Claude Code |
Member
Author
|
Split into #38242 (FreeBSD) and the Android PR; closing this combined draft. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Running the full test suite (via
scripts/runner.node.mjs, as CI does) on the FreeBSD x64 and Android x64 artifacts turned up several platform-specific runtime bugs; this fixes the ones with clear root causes and teaches the runner/harness about both hosts.bun build --compile: every compiled executable segfaulted at startup. Standalone binaries are PIE on Android, so the embedded module graph's link-time vaddr now gets the load bias (found viadl_iterate_phdr) added before it is dereferenced.--compileon UFS:inject()now returns the temp path it created instead of the caller reverse-mapping fd→path (F_KINFOreturned an empty path there, so the final rename failed with ENOENT).-z stack-sizefrom the FreeBSD link. FreeBSD's exec usesPT_GNU_STACKas the main-thread stack reservation while libthr reportsRLIMIT_STACK, so overflow guards never fired and deep recursion (TOML/YAML/JSONC/transpiler tests) killed the process instead of throwingRangeError.uname: the exportedunamesymbol fills 32-byte fields; call__xuname(256, …)soutsname.releaseisn't empty (crash reports printedFreeBSD Kernel v).EV_ERROR/ENOENT|EBADF receipts from cancelling an already-fired oneshot knote; they were surfacing as read errors for FIFOs/pipes viaBun.file().openptyfromlibutilsoBun.Terminalworks.scripts/utils.mjs/test/harness.ts: recognizefreebsdandandroid.How did you verify your code works?
Linux:
bun bd build --compile(plain,--bytecode, nested--outfile) produces working binaries;test/bundler/bun-build-compile.test.tsunchanged vs main.cargo checkpasses forx86_64-unknown-freebsdandx86_64-linux-android. The FreeBSD/Android behavior changes were diagnosed on a FreeBSD 14.3 VM and an API 35 x86_64 emulator against the current artifacts; re-verification on-target is pending this PR's CI artifacts.