Address crash in the cloud cache system when doing two single byte reads. #52260
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.
The core problem here is how we prebuffer data that we read out of the cloudcache store. We do some advanced machinations with the underlying pipe where we keep our read pointer at the start, but push the examined pointer out to read in everything.
This works fine to stream all the data in, but causes a problem later if we end up doign multiple smaller reads over that as the small reads look like tehy're moving us backward versus the size of hte full read.
Note: this PR is a WIP. We are getting a new API in nerdbanks that will take care of this entire scenario of prebuffering safely. However, this PR at elast shows a test for this case, as well as a fix that works for us (albeit with an unfortunate non-pooling of pipe backing memory).