[GH-ISSUE #6074] Windows: os_version comes from the localized text of cmd /C ver, and non-ASCII letters in it are replaced with U+FFFD #1957

Closed
opened 2026-11-02 15:50:55 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @mariuslozo-boop on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6074

🤖 Filed by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally.

Three places in the Rust code read the Windows version by running cmd /C ver and decoding its output as UTF-8 with replacement. cmd writes that text in the console's OEM code page and in the Windows display language. On a Windows whose word for "Version" has a non-ASCII letter, the stored os_version has U+FFFD where the letter was, and it is not the same string as on an English Windows.

Where (all on 183b53f0e)

  • crates/horizon-telemetry/src/system.rs:48 (os_version(), the telemetry System.os_version).
  • crates/horizon-bench/src/hardware.rs:229-231 (os_version(), the benchmark report's hardware.os_version).
  • crates/horizon-client-render/src/crash.rs:223 (the crash report's "windows (x86_64) version ...").
  • All three use horizon_telemetry::system::command_output, which does String::from_utf8_lossy(&out.stdout) (system.rs:25). Nothing is dropped and nothing panics; invalid bytes become U+FFFD.

What happened on the Python side. #5201 found the same cmd /C ver bytes on a Spanish Windows 11: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 26. The console was cp850 (ó is 0xA2), and the reader printed Microsoft Windows [Versión 10.0.26200.9711]. #5210 fixed tools/perf_bench.py with encoding="oem", errors="replace". The Rust readers were not changed. (Python's strict decode failed there; Rust's lossy decode doesn't fail, it garbles.)

How it was seen. This PC is en-GB, so ver is ASCII (Microsoft Windows [Version 10.0.26300.9711]). I can't switch the display language, so a temporary test (not committed) wrote the OEM bytes of the #5201 output to a file and ran the real command_output("cmd", ["/C", "type", file]) on it:

es-ES, cp850 bytes   -> Some("Microsoft Windows [Versi�n 10.0.26200.9711]")
ru-RU, cp866 bytes   -> Some("Microsoft Windows [����� 10.0.26200.9711]")   (made-up fixture: the bytes of "Версия" in cp866)
this machine         -> Some("Microsoft Windows [Version 10.0.26300.9711]")

The Spanish bytes are the real case from #5201. The Russian line only shows what any cp866 text would do; I did not find a real Russian, Greek or Chinese ver output to quote, so I don't claim which other languages use non-ASCII words. Spanish is the confirmed one.

Effect. The telemetry server keeps os_version as text and keys a system row on it (crates/horizon-telemetry-server/src/store.rs:35, UNIQUE (os, os_version, ...)). So the same Windows build shows up as a separate row per display language, and the Spanish one holds a replacement character. Benchmark hardware.os_version and the crash report show the same garbled text. Nothing else in the repo parses the string (rg os_version crates finds only the readers, the payload field and the store), so I found no functional breakage; this is wrong data in the reports.

Not known

  • Which other Windows languages use non-ASCII words in ver; only Spanish is verified.
  • Whether a console set to UTF-8 (chcp 65001) changes anything.
Originally created by @mariuslozo-boop on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6074 > 🤖 Filed by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally. Three places in the Rust code read the Windows version by running `cmd /C ver` and decoding its output as UTF-8 with replacement. `cmd` writes that text in the console's OEM code page and in the Windows display language. On a Windows whose word for "Version" has a non-ASCII letter, the stored `os_version` has `U+FFFD` where the letter was, and it is not the same string as on an English Windows. **Where** (all on `183b53f0e`) - `crates/horizon-telemetry/src/system.rs:48` (`os_version()`, the telemetry `System.os_version`). - `crates/horizon-bench/src/hardware.rs:229-231` (`os_version()`, the benchmark report's `hardware.os_version`). - `crates/horizon-client-render/src/crash.rs:223` (the crash report's "windows (x86_64) version ..."). - All three use `horizon_telemetry::system::command_output`, which does `String::from_utf8_lossy(&out.stdout)` (`system.rs:25`). Nothing is dropped and nothing panics; invalid bytes become `U+FFFD`. **What happened on the Python side.** #5201 found the same `cmd /C ver` bytes on a Spanish Windows 11: `UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 26`. The console was cp850 (`ó` is `0xA2`), and the reader printed `Microsoft Windows [Versión 10.0.26200.9711]`. #5210 fixed `tools/perf_bench.py` with `encoding="oem", errors="replace"`. The Rust readers were not changed. (Python's strict decode failed there; Rust's lossy decode doesn't fail, it garbles.) **How it was seen.** This PC is en-GB, so `ver` is ASCII (`Microsoft Windows [Version 10.0.26300.9711]`). I can't switch the display language, so a temporary test (not committed) wrote the OEM bytes of the #5201 output to a file and ran the real `command_output("cmd", ["/C", "type", file])` on it: ``` es-ES, cp850 bytes -> Some("Microsoft Windows [Versi�n 10.0.26200.9711]") ru-RU, cp866 bytes -> Some("Microsoft Windows [����� 10.0.26200.9711]") (made-up fixture: the bytes of "Версия" in cp866) this machine -> Some("Microsoft Windows [Version 10.0.26300.9711]") ``` The Spanish bytes are the real case from #5201. The Russian line only shows what any cp866 text would do; I did not find a real Russian, Greek or Chinese `ver` output to quote, so I don't claim which other languages use non-ASCII words. Spanish is the confirmed one. **Effect.** The telemetry server keeps `os_version` as text and keys a system row on it (`crates/horizon-telemetry-server/src/store.rs:35`, `UNIQUE (os, os_version, ...)`). So the same Windows build shows up as a separate row per display language, and the Spanish one holds a replacement character. Benchmark `hardware.os_version` and the crash report show the same garbled text. Nothing else in the repo parses the string (`rg os_version crates` finds only the readers, the payload field and the store), so I found no functional breakage; this is wrong data in the reports. **Not known** - Which other Windows languages use non-ASCII words in `ver`; only Spanish is verified. - Whether a console set to UTF-8 (`chcp 65001`) changes anything.
Author
Owner

@Domanffe commented on GitHub (Nov 1, 2026):

🤖 Agent: opened #6101 for this. cmd /C ver is gone from all three readers; they read CurrentBuild and UBR from HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion instead, which is ASCII in any display language. On this machine that reads Windows 11 (26200.9818) where ver said 10.0.26200.9818.

<!-- gh-comment-id:6561108264 --> @Domanffe commented on GitHub (Nov 1, 2026): 🤖 Agent: opened #6101 for this. `cmd /C ver` is gone from all three readers; they read `CurrentBuild` and `UBR` from `HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion` instead, which is ASCII in any display language. On this machine that reads `Windows 11 (26200.9818)` where `ver` said `10.0.26200.9818`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#1957
No description provided.