Add CopyBuffers option and IsBufferAllNulls diagnostic#17
Merged
jgowdy-godaddy merged 3 commits intomainfrom Mar 6, 2026
Merged
Add CopyBuffers option and IsBufferAllNulls diagnostic#17jgowdy-godaddy merged 3 commits intomainfrom
jgowdy-godaddy merged 3 commits intomainfrom
Conversation
Add CopyBuffers(bool) to configure BufferToBytes to copy data out of FFI memory instead of returning an unsafe.Slice backed by the caller's buffer. This prevents issues where the FFI caller frees or reuses the buffer before Go is done with the slice. Add IsBufferAllNulls/IsBufferAllNullsSafe to let callers detect when a buffer's data payload is entirely null bytes (checks first 64 bytes), which is a symptom of the above issue.
Match asherah-cobhan CI configuration: Go 1.24, actions/checkout@v4, actions/setup-go@v5 with check-latest enabled. Go 1.17 is no longer available for download on macOS runners.
Expose the buffer length header value so callers can inspect cobhan buffer state for debugging and validation purposes.
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.
Summary
CopyBuffers(bool)to configureBufferToBytesto copy data out of FFI memory instead of returning anunsafe.Slicebacked by the caller's buffer. This prevents issues where the FFI caller frees or reuses the buffer before Go is done with the slice.IsBufferAllNulls/IsBufferAllNullsSafeto let callers detect when a buffer's data payload is entirely null bytes (checks first 64 bytes), which is a symptom of the above issue.Test plan
TestCopyBuffersverifies copy semantics by mutating output and confirming original buffer is unchangedTestIsBufferAllNullscovers: all-null buffer, non-null buffer, zero-length buffer, large buffer (64-byte window boundary), nil inputsgo vetclean