chore: enable _GLIBCXX_DEBUG in debug build presets#22218
Merged
ludamad merged 2 commits intoApr 1, 2026
Conversation
Enable libstdc++ debug mode in the debug and debug-fast CMake presets. This catches logical container UB (e.g. operator[] on a reserved-but-empty vector) that ASAN cannot detect because the backing memory is allocated.
ludamad
approved these changes
Apr 1, 2026
AztecBot
added a commit
that referenced
this pull request
Apr 1, 2026
…X_DEBUG ASAN build hash_to_curve and ECCVMHardcodedVKAndHash::get_all() use std::vector which is not a literal type under _GLIBCXX_DEBUG (added by PR #22218). These functions are never evaluated at compile time, so constexpr is unnecessary.
3 tasks
AztecBot
added a commit
that referenced
this pull request
Apr 1, 2026
…EBUG compat hash_to_curve and ECCVMHardcodedVKAndHash::get_all() use std::vector which is not a literal type under _GLIBCXX_DEBUG (added by PR #22218). These functions are never evaluated at compile time, so constexpr is unnecessary.
johnathan79717
pushed a commit
that referenced
this pull request
Apr 2, 2026
…EBUG compat (#22239) ## Summary Fixes ASAN and debug build failures introduced by PR #22218 which added `_GLIBCXX_DEBUG` to debug/ASAN build presets. Under `_GLIBCXX_DEBUG`, `std::vector` is not a literal type (the debug wrapper lacks constexpr constructors), causing compilation errors in any `constexpr` function that uses `std::vector`. Two functions affected: - `affine_element::hash_to_curve()` — uses `std::vector<uint8_t>` internally - `ECCVMHardcodedVKAndHash::get_all()` — returns `std::vector<Commitment>` Neither function is ever evaluated at compile time, so removing `constexpr` is safe. ## Test plan - [x] ASAN preset (`asan-fast`) builds clean from scratch (1103/1103 targets, 0 failures) - [x] Debug preset builds clean from scratch (1111/1111 targets, 0 failures) - [x] Format check passes
AztecBot
added a commit
that referenced
this pull request
Apr 2, 2026
Two write() overloads in serialize.hpp used `&*buf.end()` to get a pointer to the newly-appended region after resize(). Under _GLIBCXX_DEBUG (enabled in asan-fast and debug presets since #22218), dereferencing end() triggers a debug assertion abort. Replace with `buf.data() + buf.size()` which achieves the same pointer arithmetic without dereferencing any iterator.
1 task
AztecBot
added a commit
that referenced
this pull request
Apr 2, 2026
… 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.
johnathan79717
pushed a commit
that referenced
this pull request
Apr 2, 2026
…pp (#22261) ## Summary Two `write()` overloads in `serialize.hpp` used `&*buf.end()` to obtain a raw pointer into the newly-resized region. Under `_GLIBCXX_DEBUG` (enabled in asan-fast and debug presets since #22218), dereferencing `end()` is a debug assertion abort — even though the subtracted pointer was in-bounds. Replaced with `buf.data() + buf.size()` which yields the same pointer without touching any iterator. ## Failure `ChonkTests.Basic` in the asan-fast build aborted with: ``` Error: attempt to dereference a past-the-end iterator. ``` ## Fix - `serialize.hpp:166`: `&*buf.end() - sizeof(value)` → `buf.data() + buf.size() - sizeof(value)` - `serialize.hpp:251`: `&*buf.end() - N` → `buf.data() + buf.size() - N` ## Test plan - [x] `ChonkTests.Basic` passes with debug-fast preset (`_GLIBCXX_DEBUG` enabled) ClaudeBox log: https://claudebox.work/s/4aef0cbe07a366e4?run=1
iakovenkos
pushed a commit
that referenced
this pull request
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
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
Enables libstdc++ debug mode (
_GLIBCXX_DEBUG) in thedebuganddebug-fastCMake presets.Motivation
From the BB audit:
_GLIBCXX_DEBUGcatches logical container UB that ASAN misses. For example,operator[]on areserve()d-but-empty vector is UB that ASAN cannot detect (becausereserve()allocates the backing memory — the UB is logical, not a heap overflow). With_GLIBCXX_DEBUG, libstdc++ immediately aborts with a clear diagnostic:Changes
-D_GLIBCXX_DEBUGtoCXXFLAGSin thedebugpreset-D_GLIBCXX_DEBUGtoCXXFLAGSin thedebug-fastpresetClaudeBox log: https://claudebox.work/s/638c6b632d5cd8af?run=2