From 81c004094db45a76b647adf6b8d5c0b82cfe64fa Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Tue, 17 Nov 2026 09:52:37 +0300 Subject: [PATCH] The installer's plugin service run finds its DLLs: they go beside the totk.exe it builds in temp (#845) On the release path the service run's totk.exe in /build stopped before main with 0xc0000135 (SDL3.dll not found): the DLLs are copied next to totk.exe in the install folder only by the compile step, after the lift. Every plugin was skipped with warn.plugins_skipped. The fake-tool tests did not see it; installer_test now checks the copy. exefs_plugins_test covers run()'s hang and crash reasons. Co-Authored-By: Claude Opus 5.5 --- installer/steps.py | 3 +++ tests/exefs_plugins_test.py | 16 ++++++++++++++++ tests/installer_test.py | 8 +++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/installer/steps.py b/installer/steps.py index 2510e376..70211bf0 100644 --- a/installer/steps.py +++ b/installer/steps.py @@ -997,6 +997,9 @@ class Lift(Step): if not code: code, log = run_tool(ctx, 'lift', layout.tools / 'build_game.py', build_args(ctx, gen)) if not code: + # the service run's totk.exe loads its DLLs from its own folder, as the installed one does + for dll in layout.dlls: + replace_file(dll, ctx.temp / 'build' / dll.name) code, log = run_tool(ctx, 'lift', layout.tools / 'exefs_plugins.py', [ '--exe', ctx.temp / 'build' / ('totk' + EXE), '--out', ctx.temp / 'plugins', '--mods', ctx.dest / 'mods', '--patches', patches, '--patches-out', ctx.temp / 'patches-plugins.txt', diff --git a/tests/exefs_plugins_test.py b/tests/exefs_plugins_test.py index 5243569f..071df40b 100644 --- a/tests/exefs_plugins_test.py +++ b/tests/exefs_plugins_test.py @@ -13,6 +13,7 @@ import struct import sys import tempfile import unittest +from types import SimpleNamespace from pathlib import Path ROOT = Path(__file__).resolve().parent.parent @@ -398,6 +399,7 @@ class PerPlugin(unittest.TestCase): (self.d / 'patches.txt').write_text('set fps60 TOTK_FPS60 1\n') self.runs = [] saved = xp.run, xp.hook_impls + self.real_run = xp.run self.addCleanup(lambda: (setattr(xp, 'run', saved[0]), setattr(xp, 'hook_impls', saved[1]))) xp.run, xp.hook_impls = self.fake_run, lambda rec: IMPLS @@ -444,6 +446,20 @@ class PerPlugin(unittest.TestCase): self.assertNotIn(f'mod_{key["C"].lower()}', text) self.assertIn((out / 'plugin0' / 'run1' / 'plugin0.img').resolve().as_posix(), text) + def test_run_reasons(self): + # the real run(): a hang becomes its own reason, a crash names the FATAL line + saved = xp.subprocess.run + self.addCleanup(setattr, xp.subprocess, 'run', saved) + + def hang(cmd, **kw): + raise xp.subprocess.TimeoutExpired(cmd, kw['timeout'], output=b'started', stderr=None) + xp.subprocess.run = hang + self.assertEqual(self.real_run(None, self.d / 'h', 0, 7, 'plugin0'), (None, 'its init did not return within 7 s')) + xp.subprocess.run = lambda cmd, **kw: SimpleNamespace(returncode=0xC0000005, stdout='x\nFATAL: access violation ' + '(0xc0000005) at host 1\n', stderr='') + code, why = self.real_run(None, self.d / 'c', 0, 7, 'plugin0') + self.assertEqual(why, 'its init crashed the service run: access violation (0xc0000005) at host 1') + def test_ran_view_leaves_out_plugins_that_did_not_run(self): rec = record() rec['modules'].append(dict(rec['modules'][2], name='plugin1', base=PLUGIN + 0x100000, ran=False)) diff --git a/tests/installer_test.py b/tests/installer_test.py index 57d09a32..4f8c8941 100644 --- a/tests/installer_test.py +++ b/tests/installer_test.py @@ -391,7 +391,11 @@ class LiftRunTest(unittest.TestCase): (self.dest / 'mods' / name / 'exefs').mkdir(parents=True, exist_ok=True) (self.dest / 'mods' / name / 'exefs' / 'subsdk9').write_bytes(b'NSO0' + name.encode()) plugin = self.dest / 'mods' / 'SQ' / 'exefs' / 'subsdk9' - self.ctx.layout = SimpleNamespace(**vars(self.ctx.layout), llvm='llvm', runtime='runtime', ninja='ninja', + dll = self.dest.parent / 'release-bin' / 'SDL3.dll' + dll.parent.mkdir(exist_ok=True) + dll.write_bytes(b'MZ') + (self.ctx.temp / 'build').mkdir(parents=True, exist_ok=True) + self.ctx.layout = SimpleNamespace(**vars(self.ctx.layout), llvm='llvm', runtime='runtime', ninja='ninja', dlls=[dll], deps=None, sysroot=None, runtime_lib_for=lambda cpu: None, pgo=lambda version: None, expected=lambda version: 'expected.json') saved = self.run_tool @@ -426,6 +430,8 @@ class LiftRunTest(unittest.TestCase): self.assertEqual(last[last.index('--plugins') + 1], str(plugin)) self.assertEqual(last[last.index('--patches') + 1], str(self.ctx.temp / 'patches-plugins.txt')) self.assertTrue(steps.plugins_status(self.ctx).is_file()) + # the service run's totk.exe finds its DLLs beside it + self.assertTrue((self.ctx.temp / 'build' / 'SDL3.dll').is_file()) def test_refused_plugin_is_not_lifted(self): # a refused plugin: its status line stays (the Mods tab says why), the game is lifted without it