From 65a080608af0b80c5cca9d00e412874c9bfc1424 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Tue, 10 Feb 2026 11:51:50 -0500 Subject: [PATCH] Fix stack manager references after Quetzal restore QuetzalParser._parse_stks() creates a new ZStackManager and sets it on zmachine._stackmanager, but ZCpu._stackmanager and ZOpDecoder._stack still pointed to the old empty stack. After restore, all stack ops (local var reads, routine returns, stack pops) used the wrong stack, causing the interpreter to crash on the first command. --- src/mudlib/zmachine/quetzal.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mudlib/zmachine/quetzal.py b/src/mudlib/zmachine/quetzal.py index 927e25e..730eb9d 100644 --- a/src/mudlib/zmachine/quetzal.py +++ b/src/mudlib/zmachine/quetzal.py @@ -248,6 +248,12 @@ class QuetzalParser: raise QuetzalStackFrameOverflow self._zmachine._stackmanager = stackmanager + # Update cached references in subsystems that store the stack manager + # (they cache the stack at init time and won't see the replacement) + if hasattr(self._zmachine, "_cpu"): + self._zmachine._cpu._stackmanager = stackmanager + if hasattr(self._zmachine, "_opdecoder"): + self._zmachine._opdecoder._stack = stackmanager log(" Successfully installed all stack frames.") def _parse_intd(self, data):