Skip to content

MEDIUM: EqualityChain shares an unsynchronized mutable cache — race/lost-update hazard under AsyncScheduler #625

Description

@docxology

Summary

EqualityChain (built for every variable of degree>1, variables/random.jl) shares two BitVectors (cacheleft/cacheright) and per-node mutable Message caches among all outbound mappings. materialize! (src/nodes/equality.jl:130-152) and ChainInvalidationCallback (equality.jl:169-182) read/write those structures with no lock. Under the documented ScheduleOnStreamPostprocessor(AsyncScheduler()) (postprocessors/scheduled.jl), concurrent outbound computations for different indices can tear/overwrite the cache and produce outbound messages from stale or partially-written prefix products — a silent-wrong-message hazard.

Impact / scope

  • Default single-threaded scheduler is safe; this is latent.
  • Opt-in async scheduling + high-degree variables ⇒ potential lost updates → silent wrong messages.

Suggested fix

Hold a per-chain ReentrantLock across materialize! and the invalidation callback (or use atomic cache bits and re-validate iscached before trusting a read). This is a design/trade-off change, so a PR description (not a committed branch) is drafted in prs/pr-17-equalitychain-lock.md for maintainer discussion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions