fix(bb): don't corrupt the builder in DetectsUnconstrainedWitnesses (fixes nightly debug build)#24767
Draft
AztecBot wants to merge 1 commit into
Draft
fix(bb): don't corrupt the builder in DetectsUnconstrainedWitnesses (fixes nightly debug build)#24767AztecBot wants to merge 1 commit into
AztecBot wants to merge 1 commit into
Conversation
…fixes nightly debug build)
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.
Problem
The Nightly Debug Build has failed every night since 2026-07-15 — runs 148, 149, 150. The GitHub Actions log only shows
exit status 134; the real failure is a single aborting test:134 = SIGABRT:
_GLIBCXX_DEBUG's checkedoperator[]catching a genuine out-of-bounds read.Root cause
The test fabricated an invalid builder state:
real_variable_indexholds one entry per circuit variable. For this circuitcreate_circuitallocates 19 variables, and the arithmetic block's gates reference variables 8–18 (witnesses 8/9, the constant-zero variable 10, and the default pairing-point variables 11–18). Truncating the vector to 9 entries throws away the mapping for 10 variables that gates still point at.ComponentsChecker::check()then runscdg::StaticAnalyzer_before it reaches thewitness >= real_variable_index.size()guard theresizewas aiming at, and the analyzer maps every gate wire throughreal_variable_index:So the very first arithmetic gate reads out of bounds — hence index
10, not9. This is plain UB: release builds read past the end and the test "passes"; thedebugpreset sets-D_GLIBCXX_DEBUG(CMakePresets.json), which turns it into an abort.Why it started now: nothing regressed in bb.
acir_components_checkwas developed in the private repo and landed on publicnexton 2026-07-14 via3f999a4dc4c chore(merge): Private next to public (#24686). The last green nightly (e1d2ed64d81) predates it — the module isn't in that tree at all. Run 148 was simply the first debug run that ever executed this test, and it aborted immediately. Theresize(9)was never valid here; it only ever worked where the variable layout happened to keep every gate below the truncation point.Fix
Test-only. The production code is correct as written — the analyzer is entitled to assume
real_variable_indexhas one entry per variable, and bounds-checking that hot path to accommodate a fabricated builder would be wrong.Instead the test now models the bug it actually cares about —
create_circuitdropping a constraint — without corrupting the builder: the ACIR handed to the checker links a witness pair that the built circuit never allocated a variable for, which is exactly thewitness >= real_variable_index.size()→UNCONSTRAINEDpath. The index is derived frombuilder.real_variable_index.size(), so it can't silently rot as the variable count changes — the failure mode that caused this bug.Testing
Debug preset (the failing configuration), on the failing commit
f13496502a1:index 10,container only holds 9) and confirmed the frame via lldb —graph.hpp:105under theStaticAnalyzer_constructor.acir_components_check_testspass.witness >= real_variable_index.size()guard incomponents_check.cppto hand back a real CC id makes the rewritten test fail, so it genuinely covers that guard.Notes for the reviewer
_GLIBCXX_DEBUG) failures are hiding behind it, the next nightly will surface them; this change clears the first one.debugpreset is not built by PR CI, so this PR's checks won't exercise the fix — it was verified locally as above.nextas requested for the nightly fix, rather than the usualmerge-train/barretenbergbase forbarretenberg/**.Created by claudebox · group:
slackbot· Slack thread