fix(bb): avoid out-of-bounds read in DetectsUnconstrainedWitnesses#24783
Draft
AztecBot wants to merge 1 commit into
Draft
fix(bb): avoid out-of-bounds read in DetectsUnconstrainedWitnesses#24783AztecBot wants to merge 1 commit into
AztecBot wants to merge 1 commit into
Conversation
The test corrupted the builder with real_variable_index.resize(9) while its gates still referenced variable index 10. The static analyzer indexes real_variable_index for every gate wire, so it read past the end. Release builds silently read garbage; the nightly debug preset compiles with -D_GLIBCXX_DEBUG, which turns the read into an abort (exit 134). Drive the UNCONSTRAINED path through a real mismatch instead: build the circuit from one linked pair and check it against an ACIR circuit that also references witnesses 100/101, which never become circuit variables. The builder stays internally consistent.
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.
Fixes the Nightly Debug Build failure on
next(commit 519f637).Symptom
The nightly job exited 134 (SIGABRT). The GitHub Actions log only carries the SSM wrapper; the CI dashboard log shows the build itself succeeded and a single test aborted:
with (test log):
Root cause
The test corrupted the builder to force the UNCONSTRAINED path:
That breaks a builder invariant: gates still reference variable index 10, but
real_variable_indexnow holds 9 entries.ComponentsChecker::build_circuit_component_maprunscdg::StaticAnalyzer_over the builder before its own bounds guard, and the analyzer indexesreal_variable_indexfor every gate wire — e.g.check_is_not_constant_variable:uint32_t real_variable_index = circuit_builder.real_variable_index[variable_index];So the truncation makes the analyzer read out of bounds. This is a test bug, not a product bug — the checker's own accesses to
real_variable_indexare already guarded, and a real builder is never internally inconsistent this way.It only fails at night because the
debugpreset compiles with-D_GLIBCXX_DEBUG(barretenberg/cpp/CMakePresets.json). Release/default builds use uncheckedoperator[], so the same read silently returns garbage and the test passes. Nothing regressed recently in the analyzer; the corrupting line arrived with theacir_components_checkimport, which reached publicnexton 2026-07-14.Fix
Exercise the same code path through a mismatch that can actually occur, leaving the builder consistent: build the circuit from one linked pair, then check it against an ACIR circuit that additionally references witnesses 100/101, which never become circuit variables. Those hit the checker's
witness >= real_variable_index.size()guard and are reported as UNCONSTRAINED — which is the behavior the test is meant to pin.Testing
Reproduced and verified locally with the same preset as the nightly (
cmake --preset debug -DAVM=OFF):AcirComponentsCheckTest.DetectsUnconstrainedWitnessesaborts with the identicalout-of-bounds index 10, but container only holds 9 elementsmessage, exit 134.acir_components_check_testspass.NATIVE_PRESET=debug AVM=0 NO_FAIL_FAST=1 ./bootstrap.sh testfrombarretenberg/cppcompleted with no failures (the nightly fails fast, so this confirms no second debug-only failure was hiding behind the first).Note on the base branch
Targeting
nextas the nightly-failure dispatch requested, rather than the usualmerge-train/barretenbergbase forbarretenberg/**, so the nightly recovers without waiting on the train. Happy to retarget if you'd prefer it go through the merge train.Created by claudebox · group:
slackbot· Slack thread