Repository navigation
Conversation
regress.py loads pso_offline.py from the baseline's and the candidate's trees in one process. The tool imports dmsh_abi, dmsh_side, shader_lib and others by name, so the second tree got the first tree's copies from sys.modules: a candidate that adds a dmsh_abi constant (DMSH_BLEND_OFF_FC) failed the interface check of every NVN game with the baseline's header. load_tree_module hides the non-stdlib modules already loaded while the tool runs, drops the ones it loaded afterwards (they stay bound in its globals) and restores sys.path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(PR #3190) interface_check was the only place in scripts/regress.py that loaded a revision tree's Python tool in-process via load_module. Because pso_offline.py imports dmsh_abi, dmsh_side, romfs, shader_lib and vol_space by name, the baseline and candidate shared sys.modules (and got the harness checkout's romfs), causing a candidate that adds a dmsh_abi constant (such as PR #3176's DMSH_BLEND_OFF_FC) to fail with AttributeError against the baseline's header and risking silently masking helper differences. Run pso_offline.read_pairs/pair_text and (when suspects exist) pso_offline.plan through Tree.py with JSON over stdin instead, matching how regress.py already isolates dmsh_chain and game.py. Co-authored-by: David Padron-Harris <34929160+dpadr@users.noreply.github.com>
|
Thank you @dpadr for finding and reproducing this cross-revision import sharing bug on #3176! Landed on main in e531be8 (with Co-authored-by credit for your diagnosis). Instead of hiding and restoring sys.modules in-process—which could drop newly imported standard-library modules, leave the checkout's paths on sys.path, and miss lazy imports inside functions—interface_check now runs each revision's pso_offline.py in its own Python subprocess via Tree.py (passing JSON on stdin), matching how scripts/regress.py already isolates other revision-tree tools. Checked with the full test_regress suite (71/71, including a new test covering two trees with different dmsh_abi constants, romfs helpers, and lazy imports in both orders), ruff, and a direct run of interface_check against the repository's pso_offline.py. Nothing left open here. |
…(PR seedds#3190) interface_check was the only place in scripts/regress.py that loaded a revision tree's Python tool in-process via load_module. Because pso_offline.py imports dmsh_abi, dmsh_side, romfs, shader_lib and vol_space by name, the baseline and candidate shared sys.modules (and got the harness checkout's romfs), causing a candidate that adds a dmsh_abi constant (such as PR seedds#3176's DMSH_BLEND_OFF_FC) to fail with AttributeError against the baseline's header and risking silently masking helper differences. Run pso_offline.read_pairs/pair_text and (when suspects exist) pso_offline.plan through Tree.py with JSON over stdin instead, matching how regress.py already isolates dmsh_chain and game.py. Co-authored-by: David Padron-Harris <34929160+dpadr@users.noreply.github.com> (cherry picked from commit e531be8)
Summary
regress.py checkloadspso_offline.pyfrom both the baseline's and the candidate's trees in one process, for the interface check. The tool imports its helpers by name:dmsh_abi,dmsh_side,shader_lib,romfs,vol_space. A module imported by name is cached insys.modules, so whichever tree loaded first supplied those modules to the other.How it showed up: a candidate that adds a
dmsh_abiconstant (#3176,DMSH_BLEND_OFF_FC) failed the interface check of every NVN game. The candidate's tool looked the constant up in the baseline's header:The same sharing could also hide a real difference between the trees, quietly checking both with one tree's helpers.
The fix:
load_tree_moduleloads a revision's tool with its own imports.sys.modules.sys.pathis restored.Tests
test_regress.TreeModules. Two temporary trees each ship a helper with the same name and a tool that imports it. Each tool must get its own helper;sys.pathandsys.modulesmust come back unchanged.python3 -m unittest dm.tools.tests.test_regresspasses 71/71.pso_offline.pyfrom 656f884 and a7710c4 in one process, in either order, each gets its owndmsh_abi. Main's tree gets onlydm_border_off; the candidate getsdm_border_offanddm_blend_off.regress.py check --baseline 656f8844 --candidate a7710c43on SR, Animal Well and UFO 50 finished with exit 0. The same check without it gave exit 2, with SR and Animal Well erroring.🤖 Generated with Claude Code