Skip to content

collections: write wincode vec elements via schema to match reader#197

Open
plutohan wants to merge 1 commit into
solana-program:mainfrom
plutohan:plutohan/issue-196-vec-schema-write
Open

collections: write wincode vec elements via schema to match reader#197
plutohan wants to merge 1 commit into
solana-program:mainfrom
plutohan:plutohan/issue-196-vec-schema-write

Conversation

@plutohan

@plutohan plutohan commented Jul 2, 2026

Copy link
Copy Markdown

Fixes #196.

The wincode SchemaWrite impls for TrailingVec and the prefixed-vec wrappers wrote elements as a raw byte copy sized by size_of::<T>(), while the read side decodes each element via its schema. For non-POD T those sizes disagree and the parse boundary drifts, so the field after the vector decodes wrong.

Both impls now write and size each element through SchemaWrite, matching the reader. No wire-format change for POD types. Added non-POD round-trip regression tests with a trailing field to pin the parse boundary.

@joncinque joncinque requested a review from febo July 2, 2026 11:11
@joncinque

Copy link
Copy Markdown
Contributor

@febo can you take a look?

@febo

febo commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR @plutohan! I left a comment on the issue since supporting non-pod types might affect how JS handles these types. Let's wait to see what @lorisleiva says about it.

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.

spl-collections: wincode Vec wrappers write raw bytes but read via schema

3 participants