Skip to content

fix(windows): unswallow installer failures, quote CreateProcessW args, document MotW#813

Open
DeusData wants to merge 2 commits into
mainfrom
distill/702-installer-utf8
Open

fix(windows): unswallow installer failures, quote CreateProcessW args, document MotW#813
DeusData wants to merge 2 commits into
mainfrom
distill/702-installer-utf8

Conversation

@DeusData

@DeusData DeusData commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Closes #697.

Distilled from #702 (thanks @ShauryaaSharma — credited via Co-authored-by).

What

Three Windows installer failures from #697, plus UTF-8-correct argument widening:

  1. Mark-of-the-Web silently blocks install.ps1 — README now documents Unblock-File .\install.ps1 in both install paths, plus the Set-ExecutionPolicy -Scope Process Bypass escape hatch.
  2. Agent-configuration failures were swallowedinstall.ps1 wrapped codebase-memory-mcp install -y in a try/catch that caught nothing useful (native commands don't throw) and printed "non-fatal". It now checks $LASTEXITCODE, reports the exit code, and fails the installer so users aren't left with a binary but no configured agent.
  3. taskkill /FI "IMAGENAME eq codebase-memory-mcp.exe" argument splittingcbm_exec_no_shell used _spawnvp, whose CRT concatenates argv without quoting, so the filter arrived as three bare tokens (ERROR: Invalid argument/option - 'eq'). It now builds an MSVC-convention quoted command line (cbm_build_cmdline, two-pass sizing + write, exposed for tests via compat_fs_internal.h) and spawns via CreateProcessW.
  4. UTF-8-correct widening — the quoted command line is assembled in UTF-8 bytes and converted once via the existing cbm_utf8_to_wide, so non-ASCII arguments (e.g. paths under a non-ASCII %USERPROFILE%) survive intact instead of being byte-widened as Latin-1 mojibake.

Tests

Windows-only additions to the security suite (exercised by the Windows CI leg):

  • cmdline_taskkill_filter_is_single_quoted_token — the exact Windows: install.ps1 reports success but leaves MCP server unregistered (MotW + swallowed config errors + malformed taskkill) #697 regression.
  • MSVC quoting edge cases: bare args, single arg, empty arg (""), embedded quote, trailing backslashes before the closing quote, empty argv.
  • cmdline_utf8_arg_is_widened_not_latin1 — UTF-8 C3 A9 must collapse to U+00E9, not survive as two Latin-1 code points.
  • cmdline_utf8_multibyte_roundtrips_via_utf8_to_wide — mixed 2-byte umlaut + 3-byte CJK argument round-trips identically to cbm_utf8_to_wide of the same fully-quoted UTF-8 command line; fails on Latin-1 byte-widening.
  • Live CreateProcessW spawn tests (cmd /c exit 0/42, NULL argv).

Verification

  • macOS: make -f Makefile.cbm cbm (-Werror clean), lint-ci green, security suite 34/34 (Windows-only tests compiled out; POSIX exec path unaffected — all C changes live inside the #ifdef _WIN32 branch).
  • The quoting/widening tests themselves run on the Windows CI leg; on the pre-fix Latin-1 widening (wchar_t buffer written byte-by-byte) both UTF-8 tests fail, on the cbm_utf8_to_wide path they pass.

DeusData and others added 2 commits July 3, 2026 20:15
…, document MotW

Distilled from PR #702 (fixes #697):

- install.ps1: replace the try/catch that swallowed `codebase-memory-mcp
  install` failures with a $LASTEXITCODE check that reports the exit
  code and fails the installer, instead of silently leaving no coding
  agent configured.
- README: document Unblock-File for the Mark-of-the-Web restriction
  that blocks the downloaded install.ps1, plus the execution-policy
  escape hatch.
- cbm_exec_no_shell (Windows): switch from _spawnvp, whose CRT does not
  quote arguments containing spaces (the taskkill filter "IMAGENAME eq
  codebase-memory-mcp.exe" arrived as three bare tokens), to
  CreateProcessW over a two-pass MSVC-convention quoted command line
  (cbm_build_cmdline, exposed for tests via compat_fs_internal.h).
- UTF-8-correct widening: the quoted command line is assembled in UTF-8
  bytes and converted once via cbm_utf8_to_wide, so non-ASCII arguments
  (e.g. a non-ASCII %USERPROFILE%) survive intact instead of being
  byte-widened as Latin-1 mojibake.
- tests: regression guard for the #697 taskkill filter, MSVC quoting
  edge cases (empty arg, embedded quote, trailing backslashes), UTF-8
  widening guards (2-byte sequence with explicit code points; mixed
  2-/3-byte round-trip via cbm_utf8_to_wide), and live CreateProcessW
  spawn tests. All Windows-only, exercised by the Windows CI leg.

Co-authored-by: ShauryaaSharma <shauryasofficial27@gmail.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData DeusData enabled auto-merge July 3, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: install.ps1 reports success but leaves MCP server unregistered (MotW + swallowed config errors + malformed taskkill)

1 participant