Repository navigation
fix(validate): reject nullable borrow buffer parameters - #12
Merged
Sam Gammon (sgammon) merged 1 commit intoOct 26, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Sam Gammon (sgammon)
approved these changes
Oct 26, 2026
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.
Detail bug report: View on Detail
Bug
OwnershipValidatorguards theborrow(call-buffer) feature of the.seamDSL, whose purpose is to reject any native declaration the generated ownership wrappers cannot faithfully honor — even in relaxed mode. It never rejected anullable=true(or defaulted-nullable) buffer parameter on aborrowdeclaration, even though generated Java/Rust wrappers can never deliver NULL to the native callee:byte[]overloads dereference.lengthand can't takenull.&[u8]and passesbytes.as_ptr(), always non-null.The DSL defaults pointer params to
nullable=true, so simply omittingnullable=falseon aborrowbuffer silently advertised a NULLable ABI contract the bindings violate, in both relaxed and strict mode. The borrow loop validated type, ownership, access, length type, andnocapture/readonlyfacts, but omitted the!p.nullable()check its sibling resource-destroy rule already enforced for ownership-scoped pointers. Introduced in d62ce47.Fix
Added
require(!p.nullable(), "call buffer requires non-null ptr<u8>")to the borrow loop inOwnershipValidator, mirroring the existing resource-destroy nullability rule. This aligns with the validator's philosophy of rejecting unhonorable contracts loudly rather than emitting wrappers that silently misbehave.Testing
mvn -B verify→ 159/159 tests, "All coverage checks have been met".rejectsUnsafeOrUnsupportedContractsEvenRelaxedenumeration (omittednullable=falseand explicitnullable=true), plusrejectsNullableBorrowBufferInBothModes, which asserts rejection in both relaxed and strict mode with the exact message and a non-nullable control that still generates.--relaxedand strict mode; the unmodifiedexamples/ownership.seamstill validates and generates identicalseam.rsborrow wrappers;examples/elide_lzma.seam(metadata-onlyownership=borrowed, noresource/borrowdeclaration) is unaffected.Closes #10
Automatic Fixes PRs can be configured here.