Skip to content

Add CopyBuffers option and IsBufferAllNulls diagnostic#17

Merged
jgowdy-godaddy merged 3 commits intomainfrom
add-copy-buffers-and-null-check
Mar 6, 2026
Merged

Add CopyBuffers option and IsBufferAllNulls diagnostic#17
jgowdy-godaddy merged 3 commits intomainfrom
add-copy-buffers-and-null-check

Conversation

@jgowdy-godaddy
Copy link
Contributor

Summary

  • 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.

Test plan

  • TestCopyBuffers verifies copy semantics by mutating output and confirming original buffer is unchanged
  • TestIsBufferAllNulls covers: all-null buffer, non-null buffer, zero-length buffer, large buffer (64-byte window boundary), nil inputs
  • All 16 existing + new tests pass
  • go vet clean

jgowdy added 3 commits March 6, 2026 09:54
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.
@jgowdy-godaddy jgowdy-godaddy merged commit c4e6d64 into main Mar 6, 2026
2 checks passed
@jgowdy-godaddy jgowdy-godaddy deleted the add-copy-buffers-and-null-check branch March 6, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants