CLAUDE.md: record the write/read rule this header already states in its own docs - #24
Merged
Conversation
serialize.h says it at :870, :918 and :933 -- 'All checking is performed by debug asserts on write.' I audited this header, quoted that line in my own notes, and filed the write path as a defect anyway. Recording it so the next pass does not. Also records two things worth keeping. The BitWriter bytes%8 contract really is load-bearing -- a 100-byte buffer written to exactly capacity flushes four bytes past the end, proved with a canary -- and it is still caller responsibility, which is why yojimbo masks its packet size deliberately. And a warning about the tool: ASan does NOT report that overflow. It is a partial-granule write and ASan is blind to it; an identical raw memcpy is also unreported. I nearly recorded 'no ASan report' as evidence of safety here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
serialize.hsays it at :870, :918 and :933 — "All checking is performed by debug asserts on write." That is the contract. I audited this header, quoted that exact line in my own notes, and filed the write path as a defect anyway. Recording it so the next pass doesn't.Two things worth keeping from the audit:
bytes % 8contract is genuinely load-bearing. A 100-byte buffer written to exactly capacity — within capacity, violating no assert even in debug — flushes 8 bytes at offset 96, four past the end. Proved with a canary. Still caller responsibility, which is why yojimbo masks its packet size deliberately (yojimbo_connection.cpp:248).memcpyis also unreported. I nearly recorded "no ASan report" as evidence of safety. Anyone doing sanitizer work in this header needs a canary region instead.The read path is confirmed clean by two independent audits, with the specific companion check for every
BitReaderassert cited.Docs only, no code change.
🤖 Generated with Claude Code