{"record":{"id":"12c3df227e8cad3f","repo":"SubtitleEdit/subtitleedit","slug":"qwen3-tts-server-exited-during-startup-code-nati","errorCode":null,"errorMessage":"qwen3-tts-server exited during startup (code {NativeExitCodeHelper.Describe(process.ExitCode)}). {hint} Output: {tail}","messagePattern":"qwen3-tts-server exited during startup \\(code (.+?)\\)\\. (.+?) Output: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/ui/Features/Video/TextToSpeech/Engines/Qwen3TtsCpp.cs","lineNumber":422,"sourceCode":"            _serverPort = port;\n            _serverModelFileName = modelFileName;\n            _serverStderr = stderrBuffer;\n            HookProcessExitOnce();\n\n            var deadline = DateTime.UtcNow.AddSeconds(120);\n            while (DateTime.UtcNow < deadline)\n            {\n                ct.ThrowIfCancellationRequested();\n                if (process.HasExited)\n                {\n                    var tail = SnapshotStderr(stderrBuffer);\n                    _serverProcess = null;\n                    _serverPort = 0;\n                    _serverModelFileName = null;\n                    // An empty tail plus a 0xC00000xx code means the loader killed it before main -\n                    // NativeExitCodeHelper explains those instead of just printing the raw number.\n                    var hint = NativeExitCodeHelper.GetHint(process.ExitCode, \"Qwen3 TTS\", GetSetFolder());\n                    throw new InvalidOperationException(\n                        $\"qwen3-tts-server exited during startup (code {NativeExitCodeHelper.Describe(process.ExitCode)}).\"\n                        + (hint == null ? string.Empty : \" \" + hint)\n                        + $\" Output: {tail}\");\n                }\n                if (await ProbeHealthAsync(port, TimeSpan.FromSeconds(1), ct))\n                {\n                    return;\n                }\n                await Task.Delay(TimeSpan.FromMilliseconds(500), ct);\n            }\n\n            var lastOutput = SnapshotStderr(stderrBuffer);\n            StopServerInternal();\n            throw new TimeoutException(\n                $\"qwen3-tts-server did not report healthy within 120s. Last output: {lastOutput}\");\n        }\n        finally\n        {","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Features/Video/TextToSpeech/Engines/Qwen3TtsCpp.cs#L404-L440","documentation":"Thrown during the startup health-wait loop when process.HasExited becomes true before the /health probe ever succeeds. The message includes NativeExitCodeHelper.Describe(ExitCode) (which translates 0xC00000xx loader-killed codes into human hints) and the captured stderr tail so the user can see why the server died pre-main.","triggerScenarios":"Missing or incompatible shared libraries (Vulkan runtime, CUDA stubs) cause the loader to kill the process with 0xC0000135/0xC000007B before main; the model GGUF path is wrong so the server aborts during init; the talker/codec files are corrupt; GPU driver mismatch.","commonSituations":"First run after a GPU driver update broke Vulkan; model files partially downloaded; running on a machine without the Visual C++ runtime the server links against; the --model-name passed doesn't match any file in the models folder.","solutions":["Read the hint from NativeExitCodeHelper — a 0xC00000xx code points at a missing DLL/loader problem, not a logic error.","Check the appended Output tail for the server's own fatal line (e.g. 'failed to load model', 'vulkan: no capable device').","Install/repair the Vulkan runtime and GPU drivers, then retry.","Verify the model file named in --model-name exists and is a complete, non-truncated download."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm required runtime libs/model files exist before spawning.\nif (!File.Exists(Path.Combine(GetSetModelsFolder(), modelFileName)))\n    throw new FileNotFoundException(\"Model file missing\", modelFileName);","typeGuard":null,"tryCatchPattern":"try { await EnsureServerRunningAsync(modelFileName, ct); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"exited during startup\"))\n{\n    // Read NativeExitCodeHelper hint + stderr tail; guide the user to install Vulkan/runtime.\n    await ShowServerStartupHelpAsync(ex.Message);\n    throw;\n}","preventionTips":["Install/repair the Vulkan runtime and GPU drivers before first use.","Verify model GGUFs are complete downloads before launching.","Run the server manually once to confirm its shared-library dependencies resolve."],"tags":["tts","qwen3-tts","server-process","startup","vulkan","csharp"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}