Skip to content

Restore pending threads on atomic rollback - #20

Open
VhRvo wants to merge 1 commit into
harmonylang:masterfrom
VhRvo:codex/fix-atomic-spawn-rollback
Open

VhRvo wants to merge 1 commit into
harmonylang:masterfrom
VhRvo:codex/fix-atomic-spawn-rollback

Conversation

@VhRvo

@VhRvo VhRvo commented Nov 19, 2026

Copy link
Copy Markdown

Summary

When Charm speculatively executes the start of an atomic section and rolls back before a shared store, it restores the current context while retaining entries appended to step->spawned. This can let a child run before the store, and the parent then spawns another copy when it re-executes the section. Resuming a stopped context with Go also appends entries to step->spawned and step->unstopped.

Save both counts at the existing rollback checkpoint and restore them with the context. Entries already pending before entering the atomic section are preserved.

Regression test

test/atomic_spawn_rollback.hny spawns one child before the atomic section and a second child inside it, before writing a shared flag. The second child must observe the new flag, and both children must run exactly once. runall.scr checks the model checker's result in the .hco report.

On macOS arm64 with Python 3.13, the test reports Safety violation on the unpatched master and No issues with this patch. A print-based reproduction goes from the erroneous traces False, True and True, True to a single True. A separate reproduction using Go also passes after the patch.

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