Repository navigation
Fix race inflate - #120
Merged
Merged
Fix race inflate#120
Conversation
The `ptr.value` could theoretically be cleared by: 1. sharing the pointer value with another request 2. being schedule after the other request completes, but causes the cache to clear the value in the interim because of age etc
The cached value can be cleared theoretically because of the `.bump()` in `inflate()`. The new test makes this consistent by setting the maxCacheSize to `0` so every bump gc's the cached value.
The inflate wrapper could re-insert a pointer that lost its value between the inner inflate and its own bump, so put the value back first. The cache now evicts an existing pointer for the same id on first insert, unless a write has it pinned. Eviction lives in _remove, which reports whether the node was pinned, and gc, empty and bump act on that. Removing the newest node now promotes the previous newest instead of the oldest. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
The
.inflate()method can possibly returnnullbecause of the value being inflated being cleared from the pointer when calling.bump(). Seems most likely while there are parallel inflations.The test makes this edgecase consistent by setting the cache to
maxCacheSizeof0. This causes a single inflation to evict it's own value before returning it.Made with help from AI.