Skip to content

Keep weighted_distribution_ in sync with records_ when pruning all-zero weights. - #2275

Merged
copybara-service[bot] merged 1 commit into
mainfrom
cl/1000889284
Oct 19, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
cl/1000889284

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Keep weighted_distribution_ in sync with records_ when pruning all-zero weights.

When all corpus inputs have weight zero, WeightedDistribution::RemoveRandomWeightedSubset removes every entry from weighted_distribution_ before returning subset_to_remove. Corpus::Prune then erases one index from subset_to_remove so records_ retains one random input, leaving weighted_distribution_ empty and causing check failures on subsequent corpus operations.

Restore one zero weight in weighted_distribution_ when keeping that fallback input, and add a unit test covering Corpus::Prune with all-zero weights.

@copybara-service
copybara-service Bot force-pushed the cl/1000889284 branch 2 times, most recently from c16dfdd to b1576ee Compare October 19, 2026 20:41
…l-zero weights.

When all corpus inputs have weight zero, `WeightedDistribution::RemoveRandomWeightedSubset` removes every entry from `weighted_distribution_` before returning `subset_to_remove`. `Corpus::Prune` then erases one index from `subset_to_remove` so `records_` retains one random input, leaving `weighted_distribution_` empty and causing check failures on subsequent corpus operations.

Restore one zero weight in `weighted_distribution_` when keeping that fallback input, and add a unit test covering `Corpus::Prune` with all-zero weights.

PiperOrigin-RevId: 1002585725
@copybara-service
copybara-service Bot merged commit 7a6384e into main Oct 19, 2026
2 checks passed
@copybara-service
copybara-service Bot deleted the cl/1000889284 branch October 19, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant