mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4675] [Engine] First-run install and strata launch die in a subprocess reader thread on non-UTF-8 Windows (GBK device name vs PYTHONUTF8=1) #2128
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2128
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kongh9 on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4675
Version: Strata desktop 0.2.7 (Control 0.1.52, bundled CPython 3.12.15) and Strata Terminal 0.1.54 — both reproduce, in different files.
OS: Windows 10 22H2 (10.0.19045), Simplified Chinese: ACP and OEM code page 936 (GBK). GPU path is unrelated — this fails before any GPU/CUDA decision is reached.
Symptom
Desktop 0.2.7 — the first-run wizard fails every time with
the last install failed(12 identical attempts here). Its own diagnostics show:and
install/.strata-mcp/setup.log:Nothing is downloaded and no GPU decision is made — it dies inside Step 1.
Strata Terminal 0.1.54 —
strata launchprints the same shape, at a different offset (the offset only depends on which row of the WMI table comes first, see below):Root cause
Three facts that only break when combined:
Strata forces UTF-8 mode on the installer process.
host/server/control-runtime.mjs,controlEnvironment()putsPYTHONUTF8: '1'after the{ ...env }spread, so a user- or system-levelPYTHONUTF8can never win. Same ininstallerEnvironment()/native-control.mjs.bin/strata.cmd:10→set "PYTHONUTF8=1", andbin/strata.ps1:54→$env:PYTHONUTF8 = '1'.In UTF-8 mode
locale.getpreferredencoding(False)returnsutf-8(measured:utf8_mode: 1).The subprocess readers decode that output with no error policy.
setup.py's helper (0.1.52 line 935, 0.1.54 line 938):text=Truewith noerrors=→ strict UTF-8 decoding. The same pattern is intools/strata_mcp.py:348(run_quiet()) and, new in 0.1.54, instrata_control/engine_component.py:632.PowerShell 5.1 writes that pipe in the OEM code page (936), not UTF-8.
_win_display_adapters()asks forWin32_VideoController, and the child has no console, soMicrosoft 基本显示适配器("Microsoft Basic Display Adapter", i.e. any GPU Windows has no vendor driver for — which is the normal state on a headless/datacentre PC) arrives as GBK bytes:BB F9is基. A reader thread raises,communicate()hands backstdout = None, and.splitlines()onNonekills setup with exit code 1.out()cannot catch it: the exception happens in the reader thread, not in the caller.Why the offset differs.
setup.py's query isName|PNPDeviceID|AdapterRAM, so the ASCII"Microsoft "prefix is 10 bytes and the first bad byte lands at position 10 — unless an earlier ASCII row precedes it, which is exactly how the desktop log got 290. Same defect, two offsets.The pattern is already known in this repo, which is why this looks like a gap rather than a decision:
setup.py:8193(0.1.52) /:8260(0.1.54) already useencoding="utf-8", errors="replace",strata_cli/launch/runner.py:667likewise, and the GBK class of bugs was fixed for the benchmark tools (#2499, #2648, #2792, #3092, #3235, #4011) and for the Russian-locale GUI paths (#3202). The subprocess readers in Step 1 were left out.Checked against
mainbefore filing:out()(line 934) and_win_display_adapters()(line 4167) are still byte-for-byte as above, and no existing issue covers this — searchedUnicodeDecodeError(19 results, allstrata_bench/CMakeLists.txt),"invalid start byte"(0),"can't decode byte"(0),_win_display_adapters(0),PYTHONUTF8(24, none about Step 1's adapter probe),splitlines(5, unrelated),"Win32_VideoController"(4, unrelated),"the last install failed"(2, unrelated).Minimal repro (60 s, no install, nothing written)
Run with the app's own interpreter, twice, and compare:
A prints
utf8_mode 1 | preferred utf-8thenstdout is None -> True; B prints the rows. Alternativelysetup.py --check(which downloads nothing) dies at Step 1 under A's environment and reaches the GPU verdict under B's.Affected machine shape: any Windows whose display language makes one adapter name non-ASCII (zh/ja/ru/...), or any PC where a GPU is running on the Microsoft basic display driver. English-only setups never see it, which probably explains why it stayed hidden.
Suggested fix
Two independent points, either alone stops the crash; both together stop the whole class:
Never let a child's code page kill a reader thread. Add an error policy to the
text=Truereads —errors="replace"insetup.py out()(already the house pattern) andtools/strata_mcp.py run_quiet(),strata_control/engine_component.py _windows_adapters_cim(); and guard the parse with(done.stdout or "")/text or ""so aNonecan never reach.splitlines().Don't identify hardware by a localizable string.
errors="replace"mangles the name, which then breaksamd_gpus_windows(): it pairs a WMI row with a display-class registry entry by comparingDriverDescwithad["name"]before readingHardwareInformation.qwMemorySize. A localized AMD adapter name would no longer match, and its VRAM would come back 0 (the same report as #3798). Matching on the PCI id it already parses (VEN_1002&DEV_xxxx) instead of the name makes that step locale-independent. Reading only the registry, asserve/telemetry.py windows_display_adapters()already does, avoids the subprocess entirely.Two more call sites of the same shape, seen while reading but not yet observed to fail here, worth sweeping at the same time:
strata_control/engine_component.py:482—if done.returncode == 0 and done.stdout.strip():with noNoneguard, and its probe isnvidia-smi --query-gpu=name(a name field). Not triggered today because NVIDIA's own device names come back in English.strata_control/engine_component.py:779(_smi_query) — same missing guard, but it only ever queriescompute_cap/driver_version, so pure ASCII; low risk.Local workarounds people on zh-CN/ja/ru Windows can use today
errors="replace"(+ theor ""guards). Caveat:currentis a version symlink and a Control/Terminal component update reverts it silently, so it has to be re-applied.Win32_VideoController(disable the driverless card, or bind a vendor driver so its name becomes English).controlEnvironment()writesPYTHONUTF8:'1'after the env spread, andbin/strata.cmd/bin/strata.ps1set it themselves, so a user- or system-levelPYTHONUTF8=0never reaches the installer.Happy to test a patch on this machine and re-run
setup.py --checkplusstrata launchagainst it.@github-actions[bot] commented on GitHub (Oct 30, 2026):
Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:
Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment
/reopen.Details: CONTRIBUTING.md
@Niko1221 commented on GitHub (Oct 31, 2026):
Fixed in 0.2.9: setup and the Terminal now read what other programs print without stopping when the text isn't UTF-8, and the graphics card list is asked for in UTF-8 too. We tested this without a Chinese Windows PC, so if the first start still fails, comment here and we'll reopen. Your write-up made this quick, thank you.