Avoid unsafe graph cloning in calc path#9610
Open
Nostrademous wants to merge 12 commits intoPathOfBuildingCommunity:devfrom
Open
Avoid unsafe graph cloning in calc path#9610Nostrademous wants to merge 12 commits intoPathOfBuildingCommunity:devfrom
Nostrademous wants to merge 12 commits intoPathOfBuildingCommunity:devfrom
Conversation
This reverts commit a9926eb.
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.
Patch set P1: make source assignment non-mutating
Files
src/Modules/ModTools.luasrc/Modules/CalcPerform.luasrc/Modules/CalcSetup.luaChanges
modLib.withSource(mod, source)sourceapplied.modLib.setSource()temporarily for compatibility, but mark it internal-only / deprecated.withSource():applyEnemyModifiers()Suggested implementation
Acceptance
Patch set P2: stop deep-copying graph objects blindly
Files
src/Modules/Common.luasrc/Classes/ModStore.luasrc/Modules/CalcActiveSkill.luasrc/Modules/CalcPerform.luaChanges
env,activeSkill,ModDB,ModList, and cache entries are graph objects, not safe deep-copy targets.copyTable()withcopyTableSafe()only at graph-risk call sites:ModStore:ScaleAddMod()mod.value/mod.value.modthat may originate from shared datacopyTable()call; keep hot-path tree copies as-is unless they can receive graph objects.assertNoSelfReference(obj, label)orgraphNodeTagchecks on cache/skill objects.Acceptance
value.modtables no longer risks recursive copy overflow.Patch set P3: replace
copyActiveSkill()with a snapshot-based clone pathFiles
src/Modules/CalcActiveSkill.luasrc/Modules/CalcTriggers.luasrc/Modules/CalcMirages.lua(if applicable in your branch)Changes
calcs.snapshotActiveSkill(skill)returning only immutable / scalar fields needed to rebuild a calc-local skill:calcs.rebuildSkillFromSnapshot(env, snapshot, actor)that resolves the skill against the new env.copyActiveSkill().srcInstanceout of the snapshot unless you use only a stable scalar key; do not carry the live object reference across clone boundaries.Why
copyActiveSkill()currently carriessupportList,actor,socketGroup,summonSkill, andsrcInstancereferences into the clone path, which defeats the idea of a safe isolated copy.Acceptance