test(acir_components_check): fix out-of-bounds abort in DetectsUnconstrainedWitnesses under debug build - #24955
Draft
AztecBot wants to merge 1 commit into
Draft
test(acir_components_check): fix out-of-bounds abort in DetectsUnconstrainedWitnesses under debug build#24955AztecBot wants to merge 1 commit into
AztecBot wants to merge 1 commit into
Conversation
…trainedWitnesses under 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 failed with exit code 134 (SIGABRT) in
acir_components_check_tests:The nightly build compiles with
-D_GLIBCXX_DEBUG(libstdc++ debug mode), which bounds-checksstd::vector::operator[]. Regular release/default builds do not, so this defect was silent there — the test "passed" on undefined behavior.Root cause
DetectsUnconstrainedWitnessescorrupted the builder with:builder.real_variable_index.resize(9);This left the builder internally inconsistent: its gates still reference variable indices ≥ 9, but
real_variable_indexwas truncated to 9 elements. WhenComponentsChecker::check()runs the static analyzer (build_circuit_component_map→StaticAnalyzer::find_connected_components), the analyzer walks the builder's gate wires and callsto_real(wire)=real_variable_index[wire]. A gate wire referencing variable index 10 then readsreal_variable_index[10]on a 9-element vector — out of bounds. Release builds read adjacent memory (UB) and happen to produce the expected result; the debug build correctly aborts.The truncation was a blunt way to simulate "an ACIR witness with no circuit-side component". It can't occur with a real builder —
real_variable_indexis always sized to hold every variable the gates reference.Fix
Exercise the same
UNCONSTRAINEDdetection path with a consistent builder — the scenario the checker actually exists to catch (the ACIR graph expects a constraint the circuit does not carry):Witness 9 therefore legitimately maps to no circuit component (hitting the
NO_CIRCUIT_CCpath inbuild_circuit_component_map), and the checker reports exactly oneUNCONSTRAINEDerror. Noreal_variable_indextruncation, no out-of-bounds read.Testing
Built and ran the target with the debug preset (
-D_GLIBCXX_DEBUG), matching the nightly:DetectsUnconstrainedWitnessesaborts (index 10, 9 elements).AcirComponentsCheckTesttests pass under the debug build.Created by claudebox · group:
slackbot· Slack thread