Investigate concurrent named call-site cache race - #23
Merged
Conversation
Co-authored-by: Ademar Gonzalez <ademar@users.noreply.github.com>
This reverts commit 6afef56.
The inline cache added in e61e8c0 stored the resolved environment, path, cell, version, combiner and eager-dispatch classification in six independently mutable fields. A caller could validate its own environment against the cache and then dispatch a combiner that another caller had already written, invoking the wrong binding and silently returning the other environment's result. Hold the resolution in one immutable object published with a single volatile reference write, so a refill is never observed half-applied. Co-authored-by: Ademar Gonzalez <ademar@users.noreply.github.com>
ademar
marked this pull request as ready for review
August 8, 2026 04:09
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.
Summary
RuntimeDispatch.NamedCallSiteEvidence
mismatches=1344mismatches=1663No fix is included yet, per the hypothesis-driven debug workflow.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches the hot path for every compiled named call site and changes cross-thread visibility of cache state; correctness is critical for multi-threaded hosts but the change is localized and covered by a concurrency regression test.
Overview
Fixes a concurrency bug in compiled named-call inline caching where separate mutable fields could be observed mid-refill, so one thread could validate against its environment and then dispatch another thread’s cached combiner.
NamedCallSitenow stores a single immutableResolvedCallSitesnapshot (environment, resolution path, binding cell/version, combiner, eager shortcut) behind onecachereference, published withVolatile.Read/Volatile.Writeinstead of updating many fields independently.Adds a parallel stress test that alternates two deep environment chains on one compiled
(f 0)site and asserts zero result mismatches under heavy concurrentInvoke.Reviewed by Cursor Bugbot for commit dc1622b. Bugbot is set up for automated code reviews on this repo. Configure here.