Reject unstructured control flow inside critical regions#1048
Merged
Conversation
jcp19
force-pushed
the
claude/gobra-atomics-soundness-bwfbid
branch
from
July 15, 2026 17:17
7cb3f75 to
97ba463
Compare
A `return`/`break`/`continue` inside a `critical` region jumps past the region's
closing `exhale` (which desugaring emits after the region body), so the opened
invariant's resources are inhaled but never given back - they leak to the caller.
In a ghost `opensInvariants` function this was accepted, because the
critical-region well-formedness check classifies every statement in a ghost
function as ghost (and thus allowed). Since `Invariant(p)` is duplicable, this
made it possible to extract an invariant's contents arbitrarily often and prove
`false`, e.g.:
ghost opensInvariants requires Invariant(Cell{x}) ensures acc(x)
func steal(x *int) {
critical Cell{x} ( unfold Cell{x}(); return )
}
Reject `return`/`break`/`continue` statements that have an enclosing critical
region, checked at the statement itself via `isEnclosingCritical`.
Add regression test atomics-critical-controlflow.gobra.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DVrhzyHHGEfmThbga93BED
jcp19
force-pushed
the
claude/gobra-atomics-soundness-bwfbid
branch
from
July 15, 2026 20:01
97ba463 to
6ab7e1a
Compare
jcp19
marked this pull request as ready for review
July 15, 2026 20: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.
No description provided.