Repository navigation
2026.9.26.2: xlings runs in a directory outside the ANSI code page and never exits silently - #613
Merged
Merged
Conversation
…ode page and never exits silently (2026.9.26.2) mcpp#693 reports that on Windows, running mcpp --version from a directory whose name contains a character outside the system's ANSI code page (for example U+1F9EA) exits with 0xC0000409 and prints nothing. Measured on a GitHub windows-latest runner (ACP 1252): the process that dies is xlings, not the released mcpp.exe. Both `xlings --version` and the xlings shim `mcpp.exe` (a copy of xlings.exe) exit 0xC0000409 with no output when the working directory is outside the ACP, and work normally in ASCII directories and in directories whose non-ASCII characters fall inside cp1252. A debugger session recorded an unhandled C++ exception whose message is "No mapping for the Unicode character exists in the target multi-byte code page" — the MSVC STL throwing std::system_error while narrowing a std::filesystem::path through the ANSI code page. src/main.cpp installed no try/catch, so the exception reached std::terminate, abort, and a fast-fail exit roughly eleven frames into start-up, before any command ran. Three changes. A UTF-8 activeCodePage application manifest is now embedded in xlings.exe. mcpp.toml gains a [resources] section compiling res/xlings.rc, a hand-written resource script that embeds res/xlings.exe.manifest at ordinal 1 (CREATEPROCESS_MANIFEST_RESOURCE_ID) as RT_MANIFEST (24). On Windows 10 1903 and later, this manifest makes the process's own ANSI code page UTF-8: std::filesystem::path::string() then returns UTF-8 instead of throwing, and the -A Win32 APIs accept UTF-8. [resources] compiles only on PE targets, so the Linux and macOS builds are unaffected; a local Linux build with the change applied produced no resource-related output. The manifest is listed under [resources] extra-inputs as well, because mcpp's .rc scanner recognises the MANIFEST keyword but not the numeric resource type (24) used here, and an undeclared input would not trigger a relink when the manifest changes. The shims xlings creates on Windows are hard links or file copies of xlings.exe (create_shim in src/core/xself/init.cpp), so they carry the same manifest. src/main.cpp now runs everything after argv handling — the owner-anchored home lookup, Config::paths(), capture_ambient_home_env(), the profile auto-upgrade, cli::run, and shim_dispatch — inside a try/catch, reporting std::exception and any other exception through xlings::log::error (the convention xlings::cli::run's own top-level handler already uses) and returning a non-zero exit code, instead of letting the exception reach std::terminate. xlings::cli::run already wraps its own dispatch; shim_dispatch and everything that runs before either of them did not have a handler. This is the fallback for hosts where the manifest has no effect — Windows older than 1903, or a build where the resource could not be embedded — and turns a silent, unattributable crash into a reported error. The macOS _Exit behaviour after dispatch is unchanged. .github/workflows/xlings-ci-windows.yml runs a new regression step, tests/e2e/ansi_code_page_directory_test.ps1, right after the release build. The script asserts the runner's registry ANSI code page is not already 65001 (otherwise the step could not exercise the code path it exists to test), builds a directory name from code points — so the workflow source stays ASCII — combining CJK characters and the U+1F9EA character from the original report, and in that directory runs the freshly built xlings.exe --version (asserting exit code 0 and the expected version string) and xlings.exe config (exercising the project-config search from that working directory). It then extracts the manifest from the built executable with mt.exe and asserts it declares activeCodePage. Version 2026.9.20.1 -> 2026.9.26.2 (mcpp.toml, src/core/config.cppm). #612 merged 2026.9.26.1 for an unrelated fix while this change was in review, so this PR takes the next number in the day's sequence rather than reusing one already released.
Sunrisepeak
force-pushed
the
fix/utf8-code-page-and-exception-boundary
branch
from
September 25, 2026 18:23
eb6be62 to
ad2ee85
Compare
…s its comment says
Sunrisepeak
pushed a commit
to mcpp-community/mcpp
that referenced
this pull request
Sep 25, 2026
…ink measured on four legs - kXlingsVersion and every xlings pin in .github move to 2026.9.26.2 (openxlings/xlings#613): xlings.exe declares the UTF-8 code page and its main has an exception boundary, so a working directory or an MCPP_HOME outside the ANSI code page no longer ends it with 0xC0000409 and no output. - test_cache_key stated the old rule, that a package's `c_standard = "c11"` is keyed; a package that spells the default and one that says nothing compile identically and now share a key. CI run 1 failed that test on every platform, and nothing else in the unit suites. - e2e 778 pins each leg to the openkal-musl and openkal-llvm-runtime pair that belongs together (the runtime pins openkal-musl exactly, and a root that pins another is refused as irreconcilable), and adds the report's aarch64 case under qemu-aarch64 and a host `-L` refused by the hermetic check. The openkal job asserts each leg ran. - docs: a macOS file name is UTF-8; `allow_host_libs` lifts the graph-link refusal rather than turning it into a warning. - The plan's implementation record carries CI run 1: every Windows row of the regression job passes, and the two xcode-27 legs fail as on main (#669).
Sunrisepeak
pushed a commit
to mcpp-community/mcpp
that referenced
this pull request
Sep 25, 2026
…ithout the host, and the level that was declared (#698) * 2026.9.26.1: paths in UTF-8, a C standard per package, a graph link without the host, and the level that was declared #693. mcpp held paths in the Windows ANSI code page, and the JSON it writes holds UTF-8 only, so every build under a non-ASCII project directory or home failed with an internal JSON exception, including names the code page can spell; a Latin-1 directory name fails the same way on Linux. mcpp.exe now declares the UTF-8 code page (res/mcpp.rc), build programs are linked with the same manifest, host tools default to it, and the new target key `windows_code_page` states it for a project's own executables. A path with no UTF-8 spelling is refused (project directory, MCPP_HOME), skipped and reported (a name inside a project), or refused by key (a build.mcpp directive), never an internal exception. The response files of the msvc dialect begin with a byte order mark, which cl.exe, link.exe and lib.exe need to read UTF-8 (measured), and Ninja's own encoding is checked when build.ninja is not ASCII. #695. `[build] c_standard` reached every C unit of the graph through the file-level $cflags, and a dependency's own value was not applied. Each package's C units now compile at that package's standard; an undeclared package at c11. #696. A link over a graph-supplied C library searched the host's library directories, so `-lm` linked glibc objects into a musl image. Such a link on ELF now carries --sysroot naming an empty directory, the hermetic check holds every -L to the store, the build directory and the graph's packages, and an unanswered -l fails with a note naming openkal-musl 0.19.2. #694. The musl -Og workaround is removed; the compile and the Finished line read one realised optimization level. Plan and measurements: .agents/docs/2026-09-25-issues-693-696-triage-and-repair-plan.md * xlings 2026.9.26.2, the key rule a test still stated, and the graph link measured on four legs - kXlingsVersion and every xlings pin in .github move to 2026.9.26.2 (openxlings/xlings#613): xlings.exe declares the UTF-8 code page and its main has an exception boundary, so a working directory or an MCPP_HOME outside the ANSI code page no longer ends it with 0xC0000409 and no output. - test_cache_key stated the old rule, that a package's `c_standard = "c11"` is keyed; a package that spells the default and one that says nothing compile identically and now share a key. CI run 1 failed that test on every platform, and nothing else in the unit suites. - e2e 778 pins each leg to the openkal-musl and openkal-llvm-runtime pair that belongs together (the runtime pins openkal-musl exactly, and a root that pins another is refused as irreconcilable), and adds the report's aarch64 case under qemu-aarch64 and a host `-L` refused by the hermetic check. The openkal job asserts each leg ran. - docs: a macOS file name is UTF-8; `allow_host_libs` lifts the graph-link refusal rather than turning it into a warning. - The plan's implementation record carries CI run 1: every Windows row of the regression job passes, and the two xcode-27 legs fail as on main (#669). * SPEC-002 rule three: a link over a graph-supplied C library searches no host directory (v1.1) --------- Co-authored-by: speak-agent <[email protected]>
Sunrisepeak
pushed a commit
to mcpp-community/mcpp
that referenced
this pull request
Sep 25, 2026
…gs (#700) The plan's status moves to landed, and its implementation record (§12.4 to §12.6, Appendix A.15) states what was released and measured: - mcpp 2026.9.26.1 (#698), xlings 2026.9.26.2 (openxlings/xlings#613), openkal-musl 0.19.2 and openkal-llvm-runtime 0.15.2, each mirrored to GitCode and checked against its GitHub sha256, and registered or indexed; - the sandbox check of the published artefacts (12 ok) and the same script against 2026.9.25.1 (exactly the six criteria the release changes fail); - mcpp-index#469's sweep (green on every platform) and its openkal measurement over four targets, where the one cell #696 makes visible, mimalloc's `-latomic` on the linux-musl rows, is filed with its owner (mcpplibs/openkal-llvm-runtime#31); - the self-review, and what remains open with the reason for each. Co-authored-by: speak-agent <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mcpp issue #693 reports that on Windows (system ANSI code page 936), running
mcpp --versionfrom a directory whose name contains a character outside the ANSI code page (for example U+1F9EA) exits with 0xC0000409 and prints nothing.A measurement on a GitHub
windows-latestrunner (ACP 1252) established that the process which dies is xlings, not the releasedmcpp.exe. Bothxlings --versionand the xlings shimmcpp.exe(a copy of xlings.exe) exit 0xC0000409 with no output when the working directory is outside the ACP, and work normally in ASCII directories and inC:\w\café(é is in cp1252). A debugger session onxlings --versionin the failing directory recorded a first-chance C++ exception (e06d7363) whosewhat()is "No mapping for the Unicode character exists in the target multi-byte code page" — the MSVC STL throwingstd::system_errorwhile narrowing astd::filesystem::paththrough the ANSI code page. It is unhandled:src/main.cpphad no try/catch at all, sostd::terminate→abort→ a fast-fail exit, roughly eleven frames into start-up, before any command runs. Embedding a UTF-8activeCodePageapplication manifest (Windows 10 1903+) was separately measured to fix the same class of failure formcpp.exe:std::filesystem::path::string()then returns UTF-8 and never throws, and the-AWin32 APIs take UTF-8.Changes
1. A UTF-8
activeCodePagemanifest embedded inxlings.exe.mcpp.tomlgains a[resources]section:res/xlings.rcembedsres/xlings.exe.manifestat ordinal 1 (CREATEPROCESS_MANIFEST_RESOURCE_ID) asRT_MANIFEST(24).[resources]compiles only on PE targets (mcppdocs/04-mcpp-toml.md§2.15), so Linux and macOS builds are unaffected; a local Linux build with this change applied built cleanly with no resource-related output. The manifest is listed underextra-inputsas well asfiles, because mcpp's.rcscanner recognizes theMANIFESTkeyword but not the numeric resource type (24) used here (confirmed by readingsrc/build/resources.cppm'sis_file_resource_keyword), so withoutextra-inputsan edit to the manifest would not trigger a relink. Onlyfilesandextra-inputsare used — both have shipped since[resources]'s original release (mcpp 2026.8.7.1), before the bootstrap pin this project uses (2026.8.8.4).The shims xlings creates on Windows are hard links or, failing that, file copies of
xlings.exe(create_shiminsrc/core/xself/init.cpp), so they carry the same manifest — no shim-specific work is needed.2. An exception boundary in
src/main.cpp. Everything after argv handling — the owner-anchored home lookup,Config::paths(),capture_ambient_home_env(), the profile auto-upgrade,cli::run, andshim_dispatch— now runs inside atry/catch. Onstd::exceptionit logsinternal error: {what()}throughxlings::log::error(the same callxlings::cli::run's own top-level handler already uses) and returns a non-zero code; on any other exception it logs a genericinternal error: unknown exceptionline.xlings::cli::runalready wraps its own dispatch (added for issue #583);shim_dispatchand everything that runs before either of them did not have a handler. This is the fallback for hosts where the manifest has no effect — Windows older than 1903, or a build where the resource could not be embedded — so the failure is reported instead of silent. The macOS_Exitbehavior after dispatch is unchanged.3. A Windows CI regression step.
.github/workflows/xlings-ci-windows.ymlruns a new step,tests/e2e/ansi_code_page_directory_test.ps1, right afterBuild (windows_release). The script:HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP) and fails with an explicit message if it is already65001(UTF-8), since the step would then prove nothing;[char]0x6D4B,[char]0x8BD5,[char]::ConvertFromUtf32(0x1F9EA)), so the workflow source stays plain ASCII, combining CJK characters and the exact U+1F9EA character from the mcpp#693 report;xlings.exe --versionin that directory and asserts exit code 0 and that the output contains the expected version string;xlings.exe configthere, exercising the project-config search from that working directory;xlings.exewithmt.exe -inputresource:<exe>;#1and asserts the extracted XML containsactiveCodePage.Version
2026.9.20.1→2026.9.26.2inmcpp.tomlandsrc/core/config.cppm(the only two version literals in the repository; confirmed by diffing the previous release commit and grepping the tree). #612 merged and released2026.9.26.1for an unrelated fix while this PR was in review, so this branch was rebased onto the newmainand takes the next number in the day's sequence rather than reusing one already published.Verification
mcpp build) succeeds with the[resources]section present, producingxlings v2026.9.26.2with no resources-related warnings or errors — confirming the section is inert on a non-PE target. Rebuilt again after rebasing ontomainpast fix: a dependency means the package in its own index; a subos's user data leaves only when the user says so (2026.9.26.1) #612, which also touchedsrc/main.cpp(a newdestructive_log::set_commandcall in the same block this PR wraps intry); the merge keeps that call, ordered before thestd::moveit needs to precede.