From cb492915cc2adc9f89a3f4e798270be013b66997 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Mon, 14 Sep 2026 07:27:51 +0800 Subject: [PATCH] 0.9.4 --- follow openkal-musl 0.13.3 Carries openkal-musl 0.13.3: a detached thread that ended stopped the program on macOS, because musl's 256-byte shared exit stack was overrun by the port's system call path; and openkal-windows 0.7.3, whose channel ends reach only the program they are placed in and whose started programs receive their arguments and directory as given. A version requirement here is exact, so consumers reach these only through this release. examples/cxx now also detaches a std::thread and waits for it to end, and the host jobs require it. --- .github/workflows/ci.yml | 4 +++- examples/cxx/src/main.cpp | 16 ++++++++++++++++ mcpp.toml | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0520427a..cdd79a93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -569,7 +569,8 @@ jobs: # # `same-source` also runs on bare metal, so it cannot start a thread; # `examples/cxx` can, and on Windows a joined std::thread was an access - # violation until openkal-musl 0.13.2 widened C++ `pthread_t`. + # violation until openkal-musl 0.13.2 widened C++ `pthread_t`; on macOS a + # detached one ending was, until openkal-musl 0.13.3. - name: A hosted C++ program above it runs on this host run: | set -euo pipefail @@ -579,6 +580,7 @@ jobs: # thread, so a difference elsewhere is reported without failing it. mcpp run --target '${{ matrix.native }}' 2>&1 | tee out.log || true grep -q 'ok: a thread is started and joined' out.log + grep -q 'ok: a detached thread runs and ends' out.log - name: The artefact for this host runs on it run: | diff --git a/examples/cxx/src/main.cpp b/examples/cxx/src/main.cpp index 8c3b3645..07aead81 100644 --- a/examples/cxx/src/main.cpp +++ b/examples/cxx/src/main.cpp @@ -19,6 +19,8 @@ #include #include #include +#include +#include // ⭐ THREE NAMES A PROGRAM ABOVE THIS STACK MAY USE, ASSERTED BY COMPILING. // @@ -82,6 +84,20 @@ int main() { check(joinable && written == 42 && !worker.joinable(), "a thread is started and joined"); } + // ⚠️ AND A DETACHED THREAD ENDS WITHOUT ENDING THE PROGRAM. musl released a + // detached thread's mapping from a 256-byte stack every exiting thread + // shares, and openkal-musl's path for the calls that end the thread overran + // it into the context table; on macOS the program stopped as the thread + // ended. Fixed in openkal-musl 0.13.3. + { + static std::atomic ran{false}; + std::thread([] { ran = true; }).detach(); + for (int i = 0; i < 400 && !ran; ++i) std::this_thread::sleep_for(std::chrono::milliseconds(5)); + // Running is reported before ending; the pause lets the thread end. + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + check(ran, "a detached thread runs and ends"); + } + // --- std::filesystem, which is the C++ face of openkal.fs --------------- namespace fs = std::filesystem; diff --git a/mcpp.toml b/mcpp.toml index d2ea818d..46484521 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1,7 +1,7 @@ [package] namespace = "mcpplibs" name = "openkal-llvm-runtime" -version = "0.9.3" +version = "0.9.4" description = "LLVM's C++ runtime libraries — libc++, libc++abi and libunwind — configured for openkal-musl rather than for a host C library." license = "Apache-2.0" authors = ["mcpplibs"] @@ -208,7 +208,7 @@ sources = [ cflags = ["-DDISABLE_AARCH64_FMV=1"] [dependencies] -openkal-musl = "0.13.2" +openkal-musl = "0.13.3" [build] cxx_standard = "c++23"