Skip to content

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

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
cl/1000889284
Open

copybara-service[bot] wants to merge 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.

…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: 1000889284

This branch has not been deployed

No deployments
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