Skip to content

Investigate concurrent named call-site cache race - #23

Merged
ademar merged 3 commits into
masterfrom
cursor/critical-bug-management-818d
Aug 8, 2026
Merged

Investigate concurrent named call-site cache race#23
ademar merged 3 commits into
masterfrom
cursor/critical-bug-management-818d

Conversation

@cursor

@cursor cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Summary

  • add bounded NDJSON diagnostics around RuntimeDispatch.NamedCallSite
  • reproduce the shared-delegate concurrency failure with the supplied stress probe
  • preserve instrumentation for the required confirmation run before implementing a fix

Evidence

  • baseline Release probe: mismatches=1344
  • instrumented Release probe: mismatches=1663
  • logs confirm both refill overwrite-before-dispatch and cache validation/check-use races

No fix is included yet, per the hypothesis-driven debug workflow.

Open in Web View Automation 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with 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.

NamedCallSite now stores a single immutable ResolvedCallSite snapshot (environment, resolution path, binding cell/version, combiner, eager shortcut) behind one cache reference, published with Volatile.Read / Volatile.Write instead 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 concurrent Invoke.

Reviewed by Cursor Bugbot for commit dc1622b. Bugbot is set up for automated code reviews on this repo. Configure here.

cursoragent and others added 3 commits August 7, 2026 11:08
Co-authored-by: Ademar Gonzalez <ademar@users.noreply.github.com>
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
ademar marked this pull request as ready for review August 8, 2026 04:09
@ademar
ademar merged commit c5d3a82 into master Aug 8, 2026
4 checks passed
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.

2 participants