test(bb): fix out-of-bounds read in acir_components_check DetectsUnconstrainedWitnesses#24703
Draft
AztecBot wants to merge 1 commit into
Draft
test(bb): fix out-of-bounds read in acir_components_check DetectsUnconstrainedWitnesses#24703AztecBot wants to merge 1 commit into
AztecBot wants to merge 1 commit into
Conversation
…nstrainedWitnesses
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 failed (exit 134 /
SIGABRT). The failing test isAcirComponentsCheckTest.DetectsUnconstrainedWitnesses:Root cause
The test deliberately corrupted the builder to simulate an unconstrained witness:
create_circuitproduces a builder with many more than 9 variables (the AssertZero over witnesses 8/9, plus pairing-point accumulators). Shrinkingreal_variable_indexto 9 entries leaves it inconsistent with the builder's own gates: those gates still reference variable indices ≥ 9. WhenComponentsChecker::check()runs the connected-components analysis,cdg::StaticAnalyzer_::to_real()doesreal_variable_index[variable_index]over every gate wire and reads past the shrunk vector.In a release build that unchecked
operator[]is a silent out-of-bounds read that happens to leave the test passing; the_GLIBCXX_DEBUGnightly build correctly traps it and aborts. This is undefined behavior in the test, not a defect in the production checker — which is only ever given an internally-consistent builder.Fix
Test-only change. Instead of corrupting
real_variable_index, keep the builder fully consistent (built from a constraint over witnesses 0/1) and feed the checker an ACIR component whose witness indices sit beyondreal_variable_index.size(). That witness has no circuit-side variable, so it exercises the sameNO_CIRCUIT_CC→UNCONSTRAINEDpath the test intends — which is also the real security property (an ACIR-connected witness missing from the synthesized circuit) — with no out-of-bounds access. The connected-components analysis now runs over an in-bounds builder.Verification
Reproduced and fixed in a local
_GLIBCXX_DEBUGbuild (cmake --preset debug):DetectsUnconstrainedWitnessesaborts with the out-of-bounds message above.DetectsUnconstrainedWitnessespasses; the fullacir_components_check_testssuite is green (10/10).No production code changed.
Created by claudebox · group:
slackbot