[GH-ISSUE #576] Windows: stopping the server with Ctrl+Break loses the conversation that MAYA_GLM_SLOT_KEEP should keep #238

Closed
opened 2026-10-29 21:23:06 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @pschaub on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/576

Note

Claude Opus 5.5 found this while testing MAYA_GLM_SLOT_KEEP on my PC, wrote a fix and tested it there. It also wrote the text below.

The problem: With MAYA_GLM_SLOT_KEEP=1 the conversation in the model should be kept when the engine ends (docs/SETTINGS.md). On Windows, when I stop the server with Ctrl+Break in its console, the conversations set aside earlier are kept, but the one in the model is lost. After the restart it is read again from token 0.

The idea: On Windows the engine ignores Ctrl+C and Ctrl+Break in serve mode, as it already ignores SIGINT and SIGTERM on Linux. The server still stops on them and ends the engine with QUIT, and the engine writes the conversation before it ends.

today   Ctrl+Break -> the engine ends at once  -> the conversation in the model is lost
fix     Ctrl+Break -> the server sends QUIT    -> the engine saves the conversation, then ends

What it brings: After a restart the last conversation goes on where it stopped instead of being read again. In my test its next turn took 2.0 s instead of 7.8 s.

Who it helps: Everyone on Windows who uses MAYA_GLM_SLOT_KEEP=1 and stops the server from its console. On Linux the engine already ignores these signals.

Why it happens: Windows sends a console's Ctrl+C and Ctrl+Break to every process in it, the engine included. The server handles both and then ends the engine with QUIT, so that the engine can write the conversation first:

github.com/mw00/project-maya@88a746c9f9/serve/server.py (L4699-L4717)

By then the engine has already ended on the event itself. On Linux it ignores these signals in serve mode for this reason. On Windows that block is compiled out and nothing takes its place (src/program/generate.cpp#L1036-L1046):

#if !defined(_WIN32)
    // serving: the server ends the engine with QUIT (or by closing its input), and the engine then sets the conversation
    // aside (STRATA_GLM_SLOT_KEEP).  A SIGTERM to the whole process group (systemd stopping a service, a supervisor
    // killing the server's group) must not end it mid-write; a server that is already gone must not end it with
    // SIGPIPE when it writes its last lines.
    if (o.serve) {
        std::signal(SIGTERM, SIG_IGN);
        std::signal(SIGINT, SIG_IGN);
        std::signal(SIGPIPE, SIG_IGN);
    }
#endif

The DeepSeek engine has the same block:

github.com/mw00/project-maya@88a746c9f9/src/ds4/ds4_main.cpp (L915-L922)

The fix adds an #else to both blocks that ignores SIGINT and SIGBREAK, which the C runtime on Windows raises for Ctrl+C and Ctrl+Break.

Measurements: Maya v1.1.27 built from source, MAYA_GLM_SLOT_KEEP=1. Two conversations of 6,165 tokens, X first, then Y, so Y is in the model at the stop. Then Ctrl+Break to the server (sent as CTRL_BREAK_EVENT to its process group, which the engine is in too), a new start, and a short follow-up to each. 2 runs per build, alternating:

after the restart without the fix with the fix
X, set aside earlier: tokens reused 6,164 of 6,206 6,164 of 6,206
X: time 2.86 / 2.89 s 2.98 / 3.56 s
Y, in the model at the stop: tokens reused 0 of 6,206 6,164 of 6,206
Y: time 7.87 / 7.77 s 1.95 / 2.03 s
slot files after the stop X only X and Y

With the fix the engine logs glm slots: saved a 6164-token conversation on shutdown (0.23 GB in 0.1 s) at the stop; without it there is no such line. The build without the fix also had an unrelated change with its switch off that touches none of these files. The signal blocks and the server's stop path are the same in v1.1.33.

I only tested Ctrl+Break with the GLM engine. Ctrl+C takes the same path (SIGINT), but I did not test it. The DeepSeek engine builds with the change, but I have not run it. A PR with the fix follows.

My setup: Maya v1.1.27 built from source, MSVC 19.44, CUDA 13.4, RTX 5090 32 GB, 64 GB DDR5, Ryzen 9 9950X3D2, Windows 11, Maya-S-v2 IQ2_XXS

Originally created by @pschaub on GitHub (Oct 27, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/576 > [!NOTE] > Claude Opus 5.5 found this while testing `MAYA_GLM_SLOT_KEEP` on my PC, wrote a fix and tested it there. It also wrote the text below. **The problem:** With `MAYA_GLM_SLOT_KEEP=1` the conversation in the model should be kept when the engine ends ([docs/SETTINGS.md](https://github.com/mw00/project-maya/blob/88a746c9f94d3c34a9ed31711ecfc64a2f03aa39/docs/SETTINGS.md?plain=1#L85)). On Windows, when I stop the server with Ctrl+Break in its console, the conversations set aside earlier are kept, but the one in the model is lost. After the restart it is read again from token 0. **The idea:** On Windows the engine ignores Ctrl+C and Ctrl+Break in serve mode, as it already ignores SIGINT and SIGTERM on Linux. The server still stops on them and ends the engine with QUIT, and the engine writes the conversation before it ends. ``` today Ctrl+Break -> the engine ends at once -> the conversation in the model is lost fix Ctrl+Break -> the server sends QUIT -> the engine saves the conversation, then ends ``` **What it brings:** After a restart the last conversation goes on where it stopped instead of being read again. In my test its next turn took 2.0 s instead of 7.8 s. **Who it helps:** Everyone on Windows who uses `MAYA_GLM_SLOT_KEEP=1` and stops the server from its console. On Linux the engine already ignores these signals. **Why it happens:** Windows sends a console's Ctrl+C and Ctrl+Break to every process in it, the engine included. The server handles both and then ends the engine with QUIT, so that the engine can write the conversation first: https://github.com/mw00/project-maya/blob/88a746c9f94d3c34a9ed31711ecfc64a2f03aa39/serve/server.py#L4699-L4717 By then the engine has already ended on the event itself. On Linux it ignores these signals in serve mode for this reason. On Windows that block is compiled out and nothing takes its place ([src/program/generate.cpp#L1036-L1046](https://github.com/mw00/project-maya/blob/88a746c9f94d3c34a9ed31711ecfc64a2f03aa39/src/program/generate.cpp#L1036-L1046)): ```cpp #if !defined(_WIN32) // serving: the server ends the engine with QUIT (or by closing its input), and the engine then sets the conversation // aside (STRATA_GLM_SLOT_KEEP). A SIGTERM to the whole process group (systemd stopping a service, a supervisor // killing the server's group) must not end it mid-write; a server that is already gone must not end it with // SIGPIPE when it writes its last lines. if (o.serve) { std::signal(SIGTERM, SIG_IGN); std::signal(SIGINT, SIG_IGN); std::signal(SIGPIPE, SIG_IGN); } #endif ``` The DeepSeek engine has the same block: https://github.com/mw00/project-maya/blob/88a746c9f94d3c34a9ed31711ecfc64a2f03aa39/src/ds4/ds4_main.cpp#L915-L922 The fix adds an `#else` to both blocks that ignores SIGINT and SIGBREAK, which the C runtime on Windows raises for Ctrl+C and Ctrl+Break. **Measurements:** Maya v1.1.27 built from source, `MAYA_GLM_SLOT_KEEP=1`. Two conversations of 6,165 tokens, X first, then Y, so Y is in the model at the stop. Then Ctrl+Break to the server (sent as CTRL_BREAK_EVENT to its process group, which the engine is in too), a new start, and a short follow-up to each. 2 runs per build, alternating: | after the restart | without the fix | with the fix | |---|---|---| | X, set aside earlier: tokens reused | 6,164 of 6,206 | 6,164 of 6,206 | | X: time | 2.86 / 2.89 s | 2.98 / 3.56 s | | Y, in the model at the stop: tokens reused | 0 of 6,206 | 6,164 of 6,206 | | Y: time | 7.87 / 7.77 s | 1.95 / 2.03 s | | slot files after the stop | X only | X and Y | With the fix the engine logs `glm slots: saved a 6164-token conversation on shutdown (0.23 GB in 0.1 s)` at the stop; without it there is no such line. The build without the fix also had an unrelated change with its switch off that touches none of these files. The signal blocks and the server's stop path are the same in v1.1.33. I only tested Ctrl+Break with the GLM engine. Ctrl+C takes the same path (SIGINT), but I did not test it. The DeepSeek engine builds with the change, but I have not run it. A PR with the fix follows. My setup: Maya v1.1.27 built from source, MSVC 19.44, CUDA 13.4, RTX 5090 32 GB, 64 GB DDR5, Ryzen 9 9950X3D2, Windows 11, Maya-S-v2 IQ2_XXS
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#238
No description provided.