fix: harden scalar metadata, panic fences, bun pointers, and poll locking - #2
Open
undivisible wants to merge 1 commit into
Open
fix: harden scalar metadata, panic fences, bun pointers, and poll locking#2undivisible wants to merge 1 commit into
undivisible wants to merge 1 commit into
Conversation
…king Derive v3 capabilities from inventory so scalar-only crates match the README quickstart. Catch panics on reactive ctor/poll/invoke and napi/wasm bridges. Read Bun owned buffers via bigint pointers instead of Number(), and drop the registry lock before poll while refusing handle wrap/reuse.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_3232b5d4-c798-430a-9310-68024cb8a5fd) |
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.
Implements the first hardening set from the burn audit (R1, R2, R3, R5).
Changes
cargo eqtsalready accepts explicitkind: functionon schema v3; this makes README-style crates honest and adds a scalar-only parse test.catch_unwindon reactive ctor, poll, invoke (sync/async), and the napi/wasm bridges, returningABI_PANIC/"eqts panic"instead of unwinding acrossextern "C". Integration tests panic in ctor,poll, andinvoke.Number()a heap pointer. Reads go through__eqtsReadOwned(toArrayBuffer(address, …)with bigint address, capped length) and free still uses the same bigint triple.poll()(and before callback encode / object invoke). Handle allocation skips live IDs and panics if theu64space is exhausted instead of wrapping to1.Tests
cargo fmt --checkviacargo fmt --all,cargo clippy --workspace --all-targets --all-features --locked -- -D warnings,cargo test --workspace --all-features --locked.Follow-ups (not in this PR)
dispose/cancel→ABI_UNKNOWN_HANDLE(JS currently treats cancel14as throw; second dispose is stillABI_OKfor idempotency)Note
Medium Risk
Changes reactive registry locking, handle allocation, and many FFI entry points; incorrect behavior could cause deadlocks, handle reuse bugs, or silent pointer truncation on Bun, though coverage is strong.
Overview
This PR hardens the eqts FFI/reactive boundary and Bun codegen from the burn audit (R1, R2, R3, R5).
Metadata now derives
capabilitiesfrom the export inventory (scalar-only crates no longer advertise reactive features). Tests assert the new capability shape for empty and reactive fixtures.Reactive runtime refactors handle registration (
insert_entry,allocate_handleskips in-use IDs and panics whenu64space is exhausted).poll_reactive,cancel_reactive, and callback enqueue cloneArcs and drop the registry mutex beforepoll()/cancel()/ encoding, avoiding deadlocks when user code re-enters the registry.Panic safety wraps reactive constructors, scalar/json exports, and
setup!ABI bridges (poll, invoke, dispose, cancel) plus napi/wasm shims incatch_unwind, returningABI_PANIC/"eqts panic"instead of unwinding acrossextern "C". Integration tests cover ctor, poll, and invoke panics.Bun loaders stop coercing heap addresses with
Number(); owned buffers are read via generated__eqtsReadOwned(toArrayBufferwith bigint address, length cap) while frees still use the bigint triple. Generator tests lock this in.Reviewed by Cursor Bugbot for commit e14f188. Configure here.