Fix AdaptiveCapacityDictionary assert with 11 elements #34313
Merged
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 #34307
AdaptiveCapacityDictionary starts with an Array and then transitions to a Dictionary after 10 elements. It uses null checks on these fields to figure out which mode it's in. However, one constructor was initializing both fields and put the object in an invalid state.
This is a Debug.Assert failure that Hao noticed when manually testing something. It's a 6.0 regression introduced with the new AdaptiveCapacityDictionary. Neither of us saw any incorrect product behavior related to the bug, but there's potential for it given the invalid state the object is in.
Related: the cookie parser shouldn't be assuming that the StringValues.Count is the cookie count. The Cookie header is supposed to be a single value so StringValues.Count would normally be 0 or 1. There is a Kestrel Http/2 bug (#26461) where you can get more values, which is how Hao ran into this issue.