engine: deep-copy ReversibleMeta in ResCopy#915
Open
karpfediem wants to merge 2 commits into
Open
Conversation
bda82ee to
462c065
Compare
purpleidea
reviewed
Apr 23, 2026
| // programming error | ||
| panic("reversible interfaces are illogical") | ||
| } | ||
| dst.SetReversibleMeta(x.ReversibleMeta()) // no need to copy atm |
Owner
There was a problem hiding this comment.
This comment is so suspicious! haha
I will dig a bit further into this patch this week, thank you!
Co-authored-by: Codex GPT 5.5 <noreply@openai.com>
Co-authored-by: Codex GPT 5.5 <noreply@openai.com>
462c065 to
625a524
Compare
Owner
|
Sorry for my delay here...
It should be deleting the created file on clean shutdown with ^C. Is that not occurring or it's not what you expected? |
b7ee313 to
cb70565
Compare
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.
Fixes a reversible-resource copy bug caused by aliasing
*ReversibleMeta.engine.ResCopy()was reusing the same reversible metadata pointer for the original resource and its copied/reversed form.Reversal setup mutates that metadata (
Disabled,Reversal), so those mutations could leak back into the original live resource.MRE
First run
Second run
Impact
This could cause the original resource to be treated as if it were itself a reversal resource during cleanup, which in turn could delete the pending reverse state that should have been preserved for a later run.
In practice, that means a normal converged reversible resource can disappear from the graph, and the next run has
nothing left to reverse.
Fix
Add
(*ReversibleMeta).Copy()and use it inengine.ResCopy()so reversible metadata is copied by value instead ofshared by pointer.
Verification
Added focused Go tests covering:
ReversibleMetaReversed()not mutating the original resourceReversalInit()not mutating the original resourceReversalCleanup()not deleting the original resource's pending reverse fileThe MCL repro is a second commit, so feel free to cherry-pick.