test(ffi): remove the toBuffer no-finalizer workaround - #61
Merged
EffortlessSteven merged 1 commit intoJul 30, 2026
Conversation
The FFI runner's `primitives` test passed `getNoopDeallocatorCallback()` to `toBuffer`/`toArrayBuffer` so it would not hit the no-finalizer path, which adopted the caller's pointer as owned and freed it on GC. That path is fixed, so the workaround only hides the coverage: drop the callback and let the compiled fixture exercise the real default, wrapping static native storage, dropping the Buffer, forcing GC, then reading the pointer again. `getNoopDeallocatorCallback` has no other users, so remove it from the symbol descriptor, the destructuring, and the fixture. The real deallocator-counter helpers stay. Without the toBuffer fix this is red: the fixture segfaults the test runner (`panic(main thread): Segmentation fault`), which is what oven-sh#35405 reports and why `run ffi > primitives` flaked on Windows.
Owner
Author
|
@coderabbitai review |
✅ Action performedReview finished.
|
WalkthroughChangesFFI deallocator callback removal
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
EffortlessSteven
merged commit Jul 30, 2026
fabca3d
into
claude/ffi-tobuffer-owned-pointer
2 checks passed
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.
Stacked on oven-sh#31753 for review. Do not merge into the base branch; this gets rebased onto
upstream/mainand submitted upstream after oven-sh#31753 lands.What this does
oven-sh#35246 enabled the compiled FFI fixture cross-platform and, in the same hunk, scoped
primitives' Buffer and added aBun.gc(true)after it. That collection segfaults, becausetoBufferwithout a finalizer adopted the caller's pointer as owned, so the test passesgetNoopDeallocatorCallback()to avoid it. oven-sh#31753 fixes the path, so the callback now only hides coverage of it.Fix: drop the callback so the compiled fixture exercises the real default: wrap static native storage, drop the Buffer, force GC, then read the pointer again.
getNoopDeallocatorCallbackhas no other users, so it goes too.Verification
Red without oven-sh#31753, green with it: on a Bun lacking the fix the fixture takes down the whole test runner with
panic(main thread): Segmentation fault at address 0x8420. That is the crash oven-sh#35405 reports, and since oven-sh#35246 the fixture runs on Windows too, so this callback is what currently keeps CI from seeing it.bun bd test ffi/ffi.test.js -t primitivesgetDeallocatorCallback,getDeallocatorBuffer,getDeallocatorCalledCountgetNoopDeallocatorCallbackreferencesrgclean acrosssrc/andtest/prettierReview map
test/js/bun/ffi/ffi.test.js:primitivescallstoBuffer(cptr, 0, 4)andtoArrayBuffer(cptr, 0, 4)with no finalizer; symbol descriptor and destructuring entry removed.test/js/bun/ffi/ffi-test.c:getNoopDeallocatorCallbackand itsnoop_deallocatorremoved.