fix: replace UB end-iterator dereference in serialize.hpp#22262
Merged
iakovenkos merged 1 commit intomerge-train/barretenbergfrom Apr 2, 2026
Merged
fix: replace UB end-iterator dereference in serialize.hpp#22262iakovenkos merged 1 commit intomerge-train/barretenbergfrom
iakovenkos merged 1 commit intomerge-train/barretenbergfrom
Conversation
… pointer arithmetic Two write() overloads in serialize.hpp used `&*buf.end()` to get a pointer to newly appended space. Dereferencing end() is undefined behavior, now caught by _GLIBCXX_DEBUG (enabled in asan-fast builds via #22218). Replace with `buf.data() + buf.size()` which is well-defined.
iakovenkos
approved these changes
Apr 2, 2026
github-merge-queue bot
pushed a commit
that referenced
this pull request
Apr 2, 2026
BEGIN_COMMIT_OVERRIDE fix: verify accumulated pairing points in native ChonkVerifier (#22224) chore: enable _GLIBCXX_DEBUG in debug build presets (#22218) feat: add --memory_profile_out flag for Chonk memory profiling (#22145) fix: disable max capacity test in debug + tiny gate separator improvements (#22215) fix: WASM build for memory_profile.cpp (#22231) fix: translator audit fixes (#22242) fix: remove constexpr from functions using std::vector for _GLIBCXX_DEBUG compat (#22239) fix: pippenger edge case (#22256) fix: avoid dereferencing past-the-end vector iterators in serialize.hpp (#22261) chore: crypto primitives external audit response 0 (#22263) feat: switch memory profiling from peak RSS to live heap usage (#22266) fix: replace UB end-iterator dereference in serialize.hpp (#22262) fix: catch exceptions in ChonkBatchVerifier::batch_check (#22270) END_COMMIT_OVERRIDE
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
Two
write()overloads inserialize.hppused&*buf.end()to get a pointer to newly appended space. Dereferencingend()is UB, now caught by_GLIBCXX_DEBUG(enabled in asan-fast builds via #22218). This causedChonkTests.Basicto abort in CI.Fix
Replace
&*buf.end() - offsetwithbuf.data() + buf.size() - offset(well-defined pointer arithmetic).Verification
ChonkTests.Basicunder asan-fast: PASSEDbarretenberg/cpp/bootstrap.sh ci: All 6148 tests passedDetailed analysis: https://gist.github.com/AztecBot/76c4c49c772843199db95099062ffeb3"
ClaudeBox log: https://claudebox.work/s/1aa27334b5d24bba?run=1