Skip to content

[std.snapshot] doc: warn that cas() is ABA-unsafe for multi-writer reclaim - #2113

Merged
paul-hammant merged 1 commit into
aether-lang-dev:mainfrom
paul-hammant:snapshot-cas-aba-note
Sep 19, 2026
Merged

paul-hammant merged 1 commit into
aether-lang-dev:mainfrom
paul-hammant:snapshot-cas-aba-note

Conversation

@paul-hammant

Copy link
Copy Markdown
Collaborator

Comment-only change to std/snapshot/module.ae. Adds an ABA WARNING to the reclamation-contract block in the header.

snapshot.cas is a plain pointer-value CAS (no generation tag). Correct for the single-writer-actor / defer-one-generation pattern the header already describes — but a multi-writer reclaiming CAS-COW silently breaks: once displaced values are actually freed, a recycled address lets a slow writer's stale cas() spuriously succeed and clobber a committed value. This is orthogonal to reader UAF (a reader grace epoch closes that, not this).

The note points readers at the fix (serialize writers, or single owner) and at #2112 (which offers a tagged-CAS as the deeper option). No code change — this is the cheap "document the contract" half of #2112 so the next multi-writer reclaimer doesn't rediscover it under contention.

Surfaced by selaenium's grid registry, which hit exactly this the instant it stopped leaking displaced tables; it works around it with a writer spinlock.

Follow-up to #2082 (the std.sync primitive that made real reclamation possible). Fixes the documentation gap tracked in #2112.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N1Vjg3yn7uc7uMXNmyJz1e

…writer reclaim

`snapshot.cas` is a plain pointer-value CAS with no generation tag. That is
correct for the single-writer-actor + defer-one-generation pattern the header
already documents, but it silently breaks a MULTI-writer reclaiming CAS-COW:
once displaced values are actually freed, a recycled address lets a slow
writer's stale cas() spuriously succeed and clobber a committed value (ABA).

This is orthogonal to reader use-after-free — a reader grace epoch (std.sync,
aether-lang-dev#2082) closes reader UAF but does nothing for writer ABA. Comment-only: adds
an ABA WARNING to the reclamation contract pointing at the fix (serialize
writers) and at aether-lang-dev#2112. No code change.

Surfaced by selaenium's grid registry, which hit exactly this the instant it
stopped leaking displaced tables; it works around it with a writer spinlock.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1Vjg3yn7uc7uMXNmyJz1e
@paul-hammant
paul-hammant merged commit fea1053 into aether-lang-dev:main Sep 19, 2026
@paul-hammant
paul-hammant deleted the snapshot-cas-aba-note branch September 19, 2026 10:50
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.

1 participant