fix(moonrun): use the shared null handle - #2222
Merged
peter-jerry-ye merged 1 commit intoSep 17, 2026
Merged
peter-jerry-ye merged 1 commit into
peter-jerry-ye merged 1 commit into
Conversation
Changed Files
|
peter-jerry-ye
force-pushed
the
codex/moonrun-async-null-conventions
branch
from
September 17, 2026 03:51
0c151dc to
11cf074
Compare
peter-jerry-ye
force-pushed
the
codex/moonrun-async-null-conventions
branch
from
September 17, 2026 05:50
11cf074 to
36d5689
Compare
2 tasks
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.
Async used literal zero for null buffers and address-info results even though these values are encoded slotmap keys. Optional process and stdio arguments also accepted zero alongside the reserved invalid Resource, mixing two different absence conventions.
Use the existing runtime null Handle, derived from
HostKey::null(), for nullable buffers, core executable-path results, TLS buffer results, address-info terminators, and null-accepting cleanup. Slotmap guarantees that this key cannot identify a live entry. Update the matching null predicates and removeINVALID_HOST_HANDLE. Optional Resources accept the sentinel returned byinvalid_fd(); other values undergo ordinary validation. Buffer leasing uses its owning table's validation directly.Nullable Handle values change, while import signatures stay the same. The supplied buffer and address-info wrappers recognize null through host predicates. TLS connection creation returns a live pending object, and setup reports initialization failures through a status and the object's error message. TLS cleanup rejects zero with
Badf; the shared null Handle remains a no-op. This deliberately stops accepting literal zero as an alias for null cleanup or absent Resources.The companion guest cleanup in moonbitlang/async#611 removes the redundant TLS connection null checks. Existing wrappers work with this host change because connection creation returns a live Handle. Merge this Moonrun change before the companion cleanup. The async submodule update remains separate.
Regression tests cover null production, predicates, cleanup, address-info termination, and core path errors, plus rejected zero, wrong-family, and stale Resource Handles. An import-level test verifies that freeing a zero TLS Handle reports
Badfon both engines. The developer guide distinguishes the unallocated null key from the live reserved invalid Resource. Further table migrations remain separate.