From 652239e206e05b3c0ce47116daec932b32f456dd Mon Sep 17 00:00:00 2001 From: Cheolmin Jo Date: Sun, 22 Nov 2026 19:37:50 +0900 Subject: [PATCH] test: replay the Windows/arm64 CI SDK for pure C static and shared modes; record the Integration at the lock fixes Adds tools/replay_c_shared_windows.py (36/36 against the CI SDK of CRT 5325cea with CLI 44fbf24; 30/36 against the published 20261118 SDK) and records the manual Integration run that passes ports (win-arm64). Co-Authored-By: Claude Sonnet 5.5 --- HISTORY.md | 7 + TODO.md | 7 + docs/acceptance/sdk_install_acceptance.md | 46 +++++ tools/replay_c_shared_windows.py | 194 ++++++++++++++++++++++ 4 files changed, 254 insertions(+) create mode 100644 tools/replay_c_shared_windows.py diff --git a/HISTORY.md b/HISTORY.md index 8ad70b5..801b0d1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -11,6 +11,13 @@ inventing commits or test results. Older months may later be summarized under ## 2026-11-22 +### Replay the Windows/arm64 CI SDK for pure C static and shared modes and the Integration at the lock fixes + +CRT `5325cea`'s CI-built Windows/arm64 SDK (not a release) with CLI `44fbf24`: independent SDK verification `OK`, native 1,041 checks, and a new `tools/replay_c_shared_windows.py` passes 36/36 (static control, shared runtime, +shared runtime + project DLL with the loaded `libc.dll` equal to the installed SDK's, a mixed-runtime refusal with no output); the published `20261118` SDK fails six of the same cases and is kept as the baseline. The manual +Integration run at `44fbf24` passes all 15 jobs, including `ports (win-arm64)`. The first scheduled run after the lock fixes is still pending. No promotion or pin change. +[Acceptance](docs/acceptance/sdk_install_acceptance.md#windowsarm64-pure-c-shared-sdk-replay-and-integration-at-44fbf24-2026-11-22). + ### Close the legacy lock-directory takeover race Review of the file-lock change found that `Lock` removed a stale legacy lock directory with `remove_all`, which could delete a lock *file* another process had created at that path in the meantime and let two processes hold the lock. The takeover now removes only the legacy `owner` file and then calls `rmdir`, which refuses a regular file; if the directory holds anything else it is left alone and the caller keeps waiting until the deadline. Verified on Windows x64 only: `store-lock-test` (9 checks) and `sdk-store-test` (113 checks) pass. The race has no deterministic test; it is closed by construction. The review also recorded two open limits in [TODO](TODO.md) (no in-process exclusion, lock files never removed). CI and other hosts are pending. diff --git a/TODO.md b/TODO.md index 85a9c0d..f15af21 100644 --- a/TODO.md +++ b/TODO.md @@ -100,8 +100,15 @@ and - [x] Linux/x86_64 clean C-provider candidate replay and early mixed-runtime refusal ([evidence](docs/acceptance/sdk_install_acceptance.md#clean-linux-c-shared-candidate-replay-2026-11-21)). SDK promotion and pin adoption, affected native hosts and Windows C++ remain open. +- [x] Windows/arm64: the CI-built SDK of CRT `5325cea` with CLI `44fbf24`: native 1,041 checks, and the pure C static, shared and shared + project DLL modes 36/36 with the loaded `libc.dll` equal to the installed SDK's + (the published `20261118` SDK fails six of the same 36 cases) + ([record](docs/acceptance/sdk_install_acceptance.md#windowsarm64-pure-c-shared-sdk-replay-and-integration-at-44fbf24-2026-11-22)). A CI artifact is not a release: promotion, pin adoption, Windows/x64 and macOS remain open. - [x] Store `Lock` replaced by an OS file lock with a multi-process regression; verified on Windows/x64 only ([HISTORY](HISTORY.md), 2026-11-22). Rerun the scheduled Integration job and Linux/macOS/arm64 before closing. + - [x] Windows/arm64: the manual Integration run at `44fbf24` passed all 15 jobs including `ports (win-arm64)`, and the native replay passes the 9-check `store-lock-test`; the `CI` run at `44fbf24` passed + all six native legs, which run `store-lock-test` as a PR test + ([record](docs/acceptance/sdk_install_acceptance.md#windowsarm64-pure-c-shared-sdk-replay-and-integration-at-44fbf24-2026-11-22)). + - [ ] The first scheduled Integration run after the lock fixes (the last one, at `8374470`, failed in `ports (win-arm64)`); it starts between 11:23 and 11:54 GMT, not at the 03:23 GMT slot. - [ ] No in-process exclusion in `Lock`: CRT `flock` is built on `fcntl` record locks, so two `Lock` objects in one process do not exclude each other. Today's stores never publish the same key from two threads of one process. Before adding threaded publication, add an in-process mutex per lock path (or a CRT per-open-file-description `flock`) and a diff --git a/docs/acceptance/sdk_install_acceptance.md b/docs/acceptance/sdk_install_acceptance.md index d2fde5d..adf1526 100644 --- a/docs/acceptance/sdk_install_acceptance.md +++ b/docs/acceptance/sdk_install_acceptance.md @@ -2240,3 +2240,49 @@ Local evidence in `/home/syszone/GitLocal/crt-p0-clean-20261121` includes initial CLI commit. `port-project-report` retains the first refusal. `port-project-report-r2` retains the corrected CLI's inputs, exact argv, runtime output, traces and result. Both runs use the same clean SDK artifact. + +## Windows/arm64 pure C shared SDK replay and Integration at `44fbf24` (2026-11-22) + +Windows/arm64 consumer replay of CRT Tranche 6.4 ([producer record](https://github.com/webos21/crt/blob/main/docs/acceptance/sdk_split_acceptance.md#windowsarm64-consumer-replay-of-the-ci-sdk-for-the-pure-c-shared-provider-2026-11-22)), +and the hosted Integration result for the lock fixes. **The SDK is a CI build, not a release:** nothing is promoted, no pin changes, no signature is claimed. + +**Inputs.** SDK: CRT `5325cea0dc0428bc79ac8a40c852a514265bf726`, artifact `sdk-windows-aarch64-5325cea...` of +[SDK integration run 45002729132](https://github.com/webos21/crt/actions/runs/45002729132) (all five hosts succeeded), label `v0.0.1-ci.45002729132`; manifest 1,721 bytes SHA-256 +`bf0942ef634a6afc74d2ed8563e518ebb692c6a6eeaf4e839223d76643c31205`, archive 69,784,515 bytes, installed content `12d7d2c82039e8a42463745a551f606b8197d420fc1e8a744b940f500f178cf8`, `bin\libc.dll` SHA-256 +`76db2c708f8b59dec8c47bee22fbf73e4eb0c7fde3bd4cad5a411411217840c5`; CRT's independent `ci_sdk_release.py verify` reports `OK` on the downloaded bytes. CLI: `44fbf24048d9c9159bedf9fe7d5fc816c87af5ea`. Windows 11 arm64, LLVM 22.1.8 +(`woa64`), roots with spaces and Hangul. Work roots were kept short: the first replays in this series failed on the 260-character path limit. + +**Native CLI replay against the new SDK (CRT's `replay_cli_contract_windows.py`).** A hosted C++ seed built the CLI, which self-built (cold 21 executed / 0 reused, warm 0 / 21) and ran its own suites under the per-run +restricted token with an empty `PATH`, hidden producer and CLI trees and job-object accounting: native **1,041** checks, archive 214, SDK store 113, port recipe 147 and store-lock 9; 625 recorded processes; the executable +(46,039,552 bytes, SHA-256 `5b932e71864e2044978670bafe3514374a67954e4b6d344987b4a91099a19bfb`) imports only `kernel32.dll` and `api-ms-win-core-synch-l1-2-0.dll`. The C variants (static library 27, shared library 25, +executable 25 checks) pass. Result SHA-256 `3302c02b...6787`. + +**C static and shared runtime modes (new `tools/replay_c_shared_windows.py`): 36/36.** The CLI above installs the SDK from its manifest pin into a private store and builds C projects with `build --sdk`, no configure step, in a cleared +environment. Result SHA-256 `a0749e62...d504`. + +| Case | Direct imports | Loaded `libc.dll` | Other | +| --- | --- | --- | --- | +| static runtime (control) | `kernel32`, `api-ms-win-core-synch` | none | warm build executes nothing, lock unchanged | +| shared runtime | `kernel32`, `libc.dll` | the installed SDK's `bin\libc.dll` | exits with `STATUS_DLL_NOT_FOUND` (0xC0000135) when the SDK `bin` is not on `PATH` | +| shared runtime + project DLL | executable: `kernel32`, `libc.dll`, `libcrt_provider.dll`; DLL: `kernel32`, `libc.dll` | the installed SDK's `bin\libc.dll`, one libc and one `errno` (checked by the program) | same start failure without the SDK `bin` | +| static executable depending on a shared library | | | refused ("a shared-library consumer must select shared runtime linkage"), no output artifact, lock untouched | + +The loaded-image path is reported by the process itself (the producer's `sdk_c_provider_windows_test.c`, SHA-256 `1ae97a42...b9bd`, and `sdk_c_provider_dso.c`, `61d36186...2a42`: identified test inputs, not CLI build inputs) and is the +installed store copy, whose bytes equal the archive's `libc.dll`. + +**Contrast with the published SDK.** The same driver and CLI against the published `v0.0.1-preview.20261118.windows.arm64.1` (manifest `354ab45f...eecc`) pass **30/36**; the six failures are the finding that the +correction fixes: the shared-runtime executable has no `libc.dll` import and loads none (it is linked like the static one), and the shared runtime + project DLL executable does not import `libc.dll` while its DLL does (two runtimes), so +it fails to run. Result SHA-256 `4ef3d82f...6561`. This preserves the old behavior as a failing baseline instead of overwriting it. + +**Integration at the lock fixes.** [Run 45009815964](https://github.com/webos21/crt-cli/actions/runs/45009815964) (`workflow_dispatch`, scope `all`, `main` at `44fbf24`, 09:54:37-10:11:14 GMT): all 15 jobs succeeded: `pins` +and `redirect` on every host and `ports` on `linux-x64`, `linux-arm64`, `macos-arm64`, `win-x64` and **`win-arm64`**. The earlier manual run [45002751384](https://github.com/webos21/crt-cli/actions/runs/45002751384) (at `753c597`) was the +last ARM64 port pass before the final lock fix. `store-lock-test` is a PR test in `.github/ci/pins.json`, and the `CI` run [45008041906](https://github.com/webos21/crt-cli/actions/runs/45008041906) at `44fbf24` passed all six native legs +(per-leg check counts were not extracted from the logs). + +**Scheduled run.** The last scheduled run, [44898897532](https://github.com/webos21/crt-cli/actions/runs/44898897532) (2026-11-21 11:23 GMT, at `8374470`), failed only in `ports (win-arm64)`; +the two before it passed. No scheduled run since the lock fixes had started when this was written (11:23 GMT on 2026-11-22; the scheduled runs have started between 11:23 and 11:54 GMT, not at the 03:23 GMT slot). +Its result is the remaining condition of the TODO item below; it is not inferred from the manual run. + +**Not covered.** Any release or promotion of the SDK and any pin change (the artifact is a CI build); the restricted-token adapter for the C replay (it uses a cleared environment, a private HOME and explicit LLVM tools; nothing is hidden and +no network is denied; the contract replay above does use the adapter); Windows/x64 and macOS CLI replays of this correction; Windows C++ `` and the curl compile options (separate CRT items); a Windows zlib or same-name provider +case (loader search differs from ELF); a second maintainer or independent review. Receipts are in the ignored local directories `cw/n1` (SDK verification, contract replay), `cw/n3` (36/36) and `cw/n4` (30/36). diff --git a/tools/replay_c_shared_windows.py b/tools/replay_c_shared_windows.py new file mode 100644 index 0000000..e6e30f3 --- /dev/null +++ b/tools/replay_c_shared_windows.py @@ -0,0 +1,194 @@ +#!/usr/bin/env python3 +"""Native Windows consumer replay of the pure C static/shared runtime modes of an installed Dev SDK, through the CLI. + +Python is a test-host tool; the consumer is the native crt-cli with a cleared environment, a private HOME and explicit LLVM +tools. The SDK is installed from its release manifest (a pinned digest) into a private store, then C projects are built with +`build --sdk` and no configure step: + + static a static-runtime executable (control): no libc.dll import, loads no libc.dll; + shared a shared-runtime executable: imports libc.dll and the process loads exactly the installed SDK's bin\\libc.dll; + shared+dll a shared-runtime executable with a project shared library: both import libc.dll, one libc, one errno; + refusal a static-runtime executable that depends on a shared library is refused before any output and leaves the lock. + +The program that reports the loaded libc.dll is the producer's own installed-SDK consumer (libc/tests/sdk_c_provider_windows_test.c +and sdk_c_provider_dso.c); they are inputs identified by SHA-256, not build inputs of the CLI. Without the SDK `bin` directory on +PATH a shared executable must fail to start. Link-time imports are read with llvm-readobj and compared with the loaded image. +This is a cleared-environment replay, not the restricted-token adapter; nothing is hidden from the consumer and no network is denied. +""" +import argparse +import hashlib +import json +import os +from pathlib import Path +import re +import shutil +import subprocess +import sys + + +def digest(path): + return hashlib.sha256(Path(path).read_bytes()).hexdigest() + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--cli', type=Path, required=True) + parser.add_argument('--release-dir', type=Path, required=True, help='directory with the SDK release manifest, archive and contract') + parser.add_argument('--manifest-name', required=True) + parser.add_argument('--manifest-sha256', required=True, help='the independently obtained manifest pin') + parser.add_argument('--c-test-source', type=Path, required=True, help='sdk_c_provider_windows_test.c') + parser.add_argument('--c-dso-source', type=Path, required=True, help='sdk_c_provider_dso.c') + parser.add_argument('--output', type=Path, required=True) + parser.add_argument('--work', type=Path, required=True, help='fresh work directory (must not exist)') + for name in ('cc', 'cxx', 'linker', 'ar', 'readobj'): + parser.add_argument('--' + name, type=Path, required=True) + args = parser.parse_args() + if os.name != 'nt': + parser.error('requires native Windows') + output, work = args.output.resolve(), args.work.resolve() + output.mkdir(parents=True) + work.mkdir(parents=True) + home, projects, inputs = work / 'home', work / 'projects', work / 'inputs' + for path in (home, projects, inputs, work / 'tmp'): + path.mkdir() + cli = work / 'crt-cli.exe' + shutil.copy2(args.cli, cli) + for source in sorted(args.release_dir.iterdir()): + if source.is_file(): + shutil.copy2(source, inputs / source.name) + manifest_path = inputs / args.manifest_name + assert digest(manifest_path) == args.manifest_sha256, 'the supplied pin is not this manifest' + manifest = json.loads(manifest_path.read_bytes()) + archive = next(a for a in manifest['assets'] if 'install' in a) + content = archive['install']['content_sha256'] + sdk_dir = home / '.crt' / 'sdks' / (archive['install']['version'] + '-' + content[:12]) + environment = {'HOME': str(home), 'USERPROFILE': str(home), 'PATH': '', 'SystemRoot': os.environ['SystemRoot'], 'LC_ALL': 'C', + 'TEMP': str(work / 'tmp'), 'TMP': str(work / 'tmp'), 'CRT_WINDOWS_SDK_LIBPATH': os.environ['CRT_WINDOWS_SDK_LIBPATH']} + tool_flags = ['--cc', str(args.cc.absolute()), '--cxx', str(args.cxx.absolute()), '--linker', str(args.linker.absolute()), '--ar', str(args.ar.absolute())] + results, commands = [], [] + + def record(case, passed, detail=''): + results.append({'case': case, 'passed': bool(passed), 'detail': str(detail)[:500]}) + print(('PASS ' if passed else 'FAIL ') + case, flush=True) + + def run(label, argv, env, expect_ok=True, timeout=1800): + index = len(commands) + done = subprocess.run([str(a) for a in argv], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, cwd=work, + timeout=timeout, stdin=subprocess.DEVNULL) + (output / f'call-{index:03}.stdout').write_text(done.stdout, encoding='utf-8') + (output / f'call-{index:03}.stderr').write_text(done.stderr, encoding='utf-8') + commands.append({'case': label, 'argv': [str(a) for a in argv], 'exit': done.returncode}) + return done + + def cli_json(label, tail, expect_ok=True, expect_text=None): + done = run(label, [cli, '--json', *tail], environment) + try: + reply = json.loads(done.stdout) + except ValueError: + reply = {} + message = json.dumps(reply.get('data', {}), ensure_ascii=False) + passed = (done.returncode == 0 and reply.get('ok') is True) if expect_ok else (done.returncode > 0 and reply.get('ok') is False) + if expect_text: + passed = passed and expect_text in message + record(label, passed, message[:300]) + return reply, passed + + def imports(binary): + text = run('imports ' + binary.name, [args.readobj, '--coff-imports', binary], os.environ.copy()).stdout + return sorted({m.lower() for m in re.findall(r'Name:\s+(\S+\.dll)', text, re.IGNORECASE)}) + + def project(name, text): + root = projects / name + cli_json('new ' + name, ['new', root, '--language', 'c']) + (root / 'crt.json').write_text(json.dumps(text, indent=2) + '\n', encoding='utf-8') + (root / 'src/main').mkdir(parents=True, exist_ok=True) + (root / 'src/test').mkdir(parents=True, exist_ok=True) + for stale in list((root / 'src/main').iterdir()) + list((root / 'src/test').iterdir()): + stale.unlink() + (root / 'include').mkdir(exist_ok=True) + return root + + def manifest_text(targets): + return {'manifest_format': 1, 'package': {'name': 'cshared', 'version': '0.1.0'}, + 'sdk': {'profile': 'dev', 'version': '*', 'target': 'native', 'storage': 'shared-immutable'}, + 'include_dirs': ['include'], 'targets': targets} + + main_c = args.c_test_source.read_text(encoding='utf-8') + dll_main_c = '#define CRT_TEST_PROJECT_DLL 1\n' + main_c + dso_c = args.c_dso_source.read_text(encoding='utf-8') + record('producer consumer sources are identified inputs', True, f'{args.c_test_source.name} {digest(args.c_test_source)[:16]} {args.c_dso_source.name} {digest(args.c_dso_source)[:16]}') + + # 1. Install the SDK from its manifest pin into the private store. + cli_json('sdk install from the pinned release manifest', ['sdk', 'install', '--archive', inputs / archive['name'], '--release-manifest', manifest_path, + '--release-manifest-sha256', args.manifest_sha256]) + record('the SDK landed in the private store', (sdk_dir / 'bin' / 'libc.dll').is_file(), str(sdk_dir)) + libc = (sdk_dir / 'bin' / 'libc.dll').resolve() + system = Path(os.environ['SystemRoot']) / 'System32' + with_sdk = {'SystemRoot': os.environ['SystemRoot'], 'PATH': str(sdk_dir / 'bin') + os.pathsep + str(system)} + bare = {'SystemRoot': os.environ['SystemRoot'], 'PATH': str(system)} + + def built_binary(root, name): + found = sorted(root.rglob(name)) + return found[0] if found else None + + def build_and_check(name, targets, sources, shared, with_dll): + root = project(name, manifest_text(targets)) + for relative, text in sources.items(): + (root / relative).write_text(text, encoding='utf-8') + reply, ok = cli_json(name + ': cold build', ['build', '--project', root, '--sdk', content, *tool_flags]) + cold = reply.get('data', {}).get('cache', {}) + lock_bound = (root / 'crt.lock').read_bytes() + reply, ok_warm = cli_json(name + ': warm build executes nothing', ['build', '--project', root]) + warm = reply.get('data', {}).get('cache', {}) + record(name + ': the cold build executed commands and the warm build none', cold.get('executed', 0) > 0 and warm.get('executed') == 0, f'cold={cold} warm={warm}') + exe = built_binary(root, 'app.exe') + record(name + ': the executable exists', exe is not None) + if exe is None: + return + found = imports(exe) + record(name + ': direct imports ' + ('include' if shared else 'exclude') + ' libc.dll', shared == ('libc.dll' in found), found) + if with_dll: + dll = built_binary(root, 'libcrt_provider.dll') or built_binary(root, 'crt_provider.dll') + record(name + ': the project DLL imports libc.dll too', dll is not None and 'libc.dll' in imports(dll), imports(dll) if dll else 'missing') + done = run(name + ': run with the SDK bin on PATH', [exe], with_sdk) + loaded = [line.split(':', 1)[1] for line in done.stdout.splitlines() if line.startswith('LIBC_DLL:')] + expected = [str(libc)] if shared else ['none'] + agree = done.returncode == 0 and 'sdk_c_provider: ok' in done.stdout and [str(Path(p).resolve()) if p != 'none' else p for p in loaded] == expected + record(name + ': the loaded image is ' + ('the installed SDK libc.dll' if shared else 'none (static runtime)'), agree, f'loaded={loaded} expected={expected} exit={done.returncode}') + if shared: + gone = run(name + ': run without the SDK bin on PATH', [exe], bare) + record(name + ': it fails to start when nothing provides libc.dll', gone.returncode != 0 and 'sdk_c_provider: ok' not in gone.stdout, f'exit={gone.returncode}') + reply, ok_run = cli_json(name + ': crt-cli run', ['run', '--project', root]) + record(name + ': the lock written by the first build is unchanged by the warm build and the run', (root / 'crt.lock').read_bytes() == lock_bound and content in lock_bound.decode('utf-8', 'replace'), + 'lock selects the installed SDK content: %s' % (content in lock_bound.decode('utf-8', 'replace'))) + + build_and_check('static', [{'name': 'app', 'kind': 'executable', 'runtime_linkage': 'static', 'sources': ['src/main/main.c']}], + {'src/main/main.c': main_c}, shared=False, with_dll=False) + build_and_check('shared', [{'name': 'app', 'kind': 'executable', 'runtime_linkage': 'shared', 'sources': ['src/main/main.c']}], + {'src/main/main.c': main_c}, shared=True, with_dll=False) + build_and_check('shared-dll', [{'name': 'crt_provider', 'kind': 'shared-library', 'sources': ['src/main/provider.c']}, + {'name': 'app', 'kind': 'executable', 'runtime_linkage': 'shared', 'sources': ['src/main/main.c'], 'dependencies': ['crt_provider']}], + {'src/main/main.c': dll_main_c, 'src/main/provider.c': dso_c}, shared=True, with_dll=True) + + # 2. A static-runtime executable depending on a shared library is a second runtime instance: refused before any output. + root = project('mixed', manifest_text([{'name': 'crt_provider', 'kind': 'shared-library', 'sources': ['src/main/provider.c']}, + {'name': 'app', 'kind': 'executable', 'runtime_linkage': 'static', 'sources': ['src/main/main.c'], 'dependencies': ['crt_provider']}])) + (root / 'src/main/main.c').write_text(dll_main_c, encoding='utf-8') + (root / 'src/main/provider.c').write_text(dso_c, encoding='utf-8') + lock_before = (root / 'crt.lock').read_bytes() + cli_json('mixed: a static executable with a shared-library dependency is refused', ['build', '--project', root, '--sdk', content, *tool_flags], expect_ok=False) + produced = [p for p in root.rglob('*') if p.is_file() and p.suffix.lower() in ('.exe', '.dll', '.o', '.obj')] + record('mixed: no output artifact and the lock is untouched', not produced and (root / 'crt.lock').read_bytes() == lock_before, [p.name for p in produced][:4]) + + summary = {'passed': all(r['passed'] for r in results), 'cases': results, 'cli_sha256': digest(cli), 'manifest_sha256': args.manifest_sha256, + 'sdk_content_sha256': content, 'libc_dll_sha256': digest(libc), 'sdk_directory': str(sdk_dir), + 'inputs': {args.c_test_source.name: digest(args.c_test_source), args.c_dso_source.name: digest(args.c_dso_source)}, + 'isolation': 'cleared environment, private HOME and explicit LLVM tools; not the restricted-token adapter; nothing hidden, no network denial'} + (output / 'result.json').write_text(json.dumps(summary, indent=2, ensure_ascii=False) + '\n', encoding='utf-8') + (output / 'commands.json').write_text(json.dumps(commands, indent=2, ensure_ascii=False) + '\n', encoding='utf-8') + print(f"{sum(r['passed'] for r in results)}/{len(results)} cases passed") + return 0 if summary['passed'] else 1 + + +if __name__ == '__main__': + sys.exit(main())