Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Linux: say it when a finite RLIMIT_RTTIME (PipeWire without rtkit) is the reason for an engine death by signal 9, warn at start, troubleshooting entry (#3238)

Niko1221c6a20b7e857b
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index ac541308b..487047dd0 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -140,6 +140,9 @@ Your PC is out of free RAM. Close other programs, or pick a smaller size (Q2_0 o
Usually not enough RAM (on Linux the system then stops the engine). Just send your message again: Strata starts the
engine by itself. If it keeps happening, close other programs or pick a smaller size.
+**On Linux the engine stops with "exit code -9", but nothing ran out of RAM.**
+Check `ulimit -R`. If it prints 0 (or any number), the desktop session sets a real-time CPU limit: the audio system (PipeWire) does that when rtkit is not installed, and every program started from the desktop inherits it. The kernel can then end a program with signal 9 and no message. Install `rtkit`, or start Strata outside the session's limits, for example `systemd-run --user --collect -p LimitRTTIME=infinity -- strata serve ...`. Strata prints a warning at start when it sees this limit.
+
**It says the prompt exceeds the context.**
The conversation is longer than the context you chose. Start a new chat, or run `SETUP.bat` and pick more
context.
diff --git a/serve/server.py b/serve/server.py
index 94a488c66..01e311414 100644
--- a/serve/server.py
+++ b/serve/server.py
@@ -102,6 +102,24 @@ def popen(what: str, args: list, role: str = "engine", **kw):
ENGINE_QUIT_WAIT_S, ENGINE_TERM_WAIT_S, ENGINE_KILL_WAIT_S = 20, 5, 20
+def rttime_limit_note() -> str:
+ """#3238: Linux only. A hard RLIMIT_RTTIME that is not unlimited (PipeWire's client module sets it to 0 when rtkit is
+ missing; every program started from that desktop inherits it) makes the kernel SIGKILL a process as soon as it
+ checks a thread with an armed CPU timer, with no OOM kill and no message. Returns one sentence naming the cause and
+ the fix, or "" when the limit is unlimited, the platform has no such limit or it cannot be read."""
+ try:
+ import resource
+ soft, hard = resource.getrlimit(resource.RLIMIT_RTTIME)
+ except (ImportError, AttributeError, OSError, ValueError):
+ return ""
+ if hard == resource.RLIM_INFINITY:
+ return ""
+ return (f"This session has a real-time CPU limit (RLIMIT_RTTIME hard limit {hard}; the desktop's audio system sets "
+ "it to 0 when rtkit is not installed). Linux can then end a program with signal 9 for no visible reason. "
+ "Install rtkit, or start Strata outside the desktop session's limits, for example: "
+ "systemd-run --user --collect -p LimitRTTIME=infinity -- strata serve ...")
+
+
def end_leftover_engines(exe: str) -> None:
"""Before an engine starts: end the ones a lost server left running (strata_control/procs.py). Only a process
this install recorded whose starter is gone, or an orphan of exactly this executable running --serve, and only
@@ -1198,6 +1216,11 @@ class StrataEngine:
if rc is not None and rc >= 0 and last: # it ended by itself: its own last words say why (#215)
return (f"The engine exited (code {rc}). Its last log line: {last} - if that does not explain it, please "
"report it at github.com/Niko1221/Strata/issues with the log.")
+ rt_note = rttime_limit_note() if rc == -9 else ""
+ if rt_note: # #3238: the kernel killed it, but not for RAM
+ return ("The engine was ended by signal 9. " + rt_note + " If dmesg (sudo dmesg | grep -i -E 'killed "
+ "process|out of memory') shows an out-of-memory kill instead, close other programs or use a smaller "
+ "model (Q2_0 / IQ2_XS).")
return ("The usual cause is running out of RAM: Linux then ends the biggest program (check: sudo dmesg | "
"grep -i -E 'killed process|out of memory'); Windows slows down instead. Close other programs or use a "
"smaller model (Q2_0 / IQ2_XS).")
@@ -7609,6 +7632,8 @@ def main(argv=None, *, lifecycle_event=None, interrupt_exit_code: int = 0) -> in
"[{\"gpus\": [0, 1]}, {\"gpus\": [2, 3]}])")
launch_args = list(sys.argv[1:] if argv is None else argv)
a = ap.parse_args(launch_args)
+ if a.engine == "strata" and (_rt := rttime_limit_note()): # #3238: say it before the first unexplained -9
+ print("[strata] WARNING: " + _rt, flush=True)
global OPENS_BROWSER
OPENS_BROWSER = bool(a.open)
# Every ordinary way of being asked to stop takes Ctrl+C's path (QUIT to the engine, then exit): SIGTERM (#96 docker
diff --git a/serve/test_server.py b/serve/test_server.py
index 12604f5aa..919fd05d7 100644
--- a/serve/test_server.py
+++ b/serve/test_server.py
@@ -4985,6 +4985,29 @@ class SilentEngine(unittest.TestCase):
engine.proc.poll.return_value = -6
self.assertIn("a hang it caught", engine.death_note())
+ def test_death_note_names_a_finite_rttime_limit_on_signal_9(self):
+ # #3238: a hard RLIMIT_RTTIME of 0 (PipeWire without rtkit) kills with -9 and no OOM; say so, not "out of RAM"
+ import sys
+ import tempfile
+ from unittest import mock
+ engine = self.bare(0.3)
+ fake = mock.MagicMock()
+ fake.RLIMIT_RTTIME = 15
+ fake.RLIM_INFINITY = -1
+ fake.getrlimit.return_value = (0, 0)
+ with tempfile.TemporaryDirectory() as d, mock.patch.dict(sys.modules, {"resource": fake}):
+ engine.log_path = os.path.join(d, "e.log")
+ open(engine.log_path, "w").close()
+ engine.proc.poll.return_value = -9
+ note = engine.death_note()
+ self.assertIn("RLIMIT_RTTIME", note)
+ self.assertIn("rtkit", note)
+ fake.getrlimit.return_value = (-1, -1) # unlimited: the old RAM hint stays
+ self.assertIn("running out of RAM", engine.death_note())
+ fake.getrlimit.return_value = (0, 0)
+ engine.proc.poll.return_value = -11 # another signal: not this cause
+ self.assertIn("running out of RAM", engine.death_note())
+
def test_prompt_chunks_set_the_wait(self):
# a PP line every second, at 100 tok/s: far over a 0.3 s silence, but each chunk is on time for its size
engine = self.bare(0.3)