From b66c61984bb7f1a67e03027d32852e37e0b91091 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Mon, 12 Oct 2026 19:37:53 +0200 Subject: [PATCH] metal: serve ends cleanly after QUIT (Metal-only _Exit) The stdin reader (a detached thread) can take in_mu after the serve scope destroyed it, when the server closes the pipe after QUIT; on macOS that lock throws and the engine ended with an abort. Inside #if STRATA_GPU_METAL: flush and _Exit(0) after the QUIT profile save. HIP (p620): generate.cpp preprocesses IDENTICAL and its object is byte-IDENTICAL against the gated tree (P2003 was unreachable for the CUDA compare; the change is preprocessor-only). --- src/program/generate.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/program/generate.cpp b/src/program/generate.cpp index 9128f368..05dc61a6 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -12537,6 +12537,13 @@ int main(int argc, char** argv) { } } save_profile("exit"); // #477: QUIT, or the server closed stdin +#if defined(STRATA_GPU_METAL) + // the stdin reader (detached above) may still take in_mu when the server closes the pipe after QUIT; on macOS + // locking that mutex once this scope has destroyed it throws (the engine ended with an abort): end here + std::fflush(stdout); + std::fflush(stderr); + std::_Exit(0); +#endif return 0; }