Skip to content

fix: replace UB end-iterator dereference in serialize.hpp#22262

Merged
iakovenkos merged 1 commit intomerge-train/barretenbergfrom
claudebox/fix-pippenger-edge-case
Apr 2, 2026
Merged

fix: replace UB end-iterator dereference in serialize.hpp#22262
iakovenkos merged 1 commit intomerge-train/barretenbergfrom
claudebox/fix-pippenger-edge-case

Conversation

@AztecBot
Copy link
Copy Markdown
Collaborator

@AztecBot AztecBot commented Apr 2, 2026

Summary

Two write() overloads in serialize.hpp used &*buf.end() to get a pointer to newly appended space. Dereferencing end() is UB, now caught by _GLIBCXX_DEBUG (enabled in asan-fast builds via #22218). This caused ChonkTests.Basic to abort in CI.

Fix

Replace &*buf.end() - offset with buf.data() + buf.size() - offset (well-defined pointer arithmetic).

Verification

  • ChonkTests.Basic under asan-fast: PASSED
  • Full barretenberg/cpp/bootstrap.sh ci: All 6148 tests passed

Detailed analysis: https://gist.github.com/AztecBot/76c4c49c772843199db95099062ffeb3"

ClaudeBox log: https://claudebox.work/s/1aa27334b5d24bba?run=1

… 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.
@AztecBot AztecBot added ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR. labels Apr 2, 2026
@iakovenkos iakovenkos marked this pull request as ready for review April 2, 2026 13:26
@iakovenkos iakovenkos merged commit 7511415 into merge-train/barretenberg Apr 2, 2026
34 of 38 checks passed
@iakovenkos iakovenkos deleted the claudebox/fix-pippenger-edge-case branch April 2, 2026 14:08
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants