[GH-ISSUE #2792] tools/strata_bench.py: UnicodeDecodeError reading CMakeLists.txt on non-UTF-8 Windows (GBK/cp932), before any measurement #1120

Closed
opened 2026-11-04 01:48:41 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Lithivm on GitHub (Oct 16, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2792

tools/strata_bench.py:564 (project_version) reads CMakeLists.txt with Path.read_text() and no encoding=, so it decodes with the OS locale code page. On a Chinese or Japanese Windows (GBK / cp932) the file's UTF-8 BOM makes the read fail and BENCH.bat dies before any measurement:

$ python tools/strata_bench.py
Starting strata-iq2_xs.json on port 8080 (loading takes 1-3 minutes; the PC may be slow meanwhile) ...
  still loading (2 s) ...
Traceback (most recent call last):
  File "D:\Strata\tools\strata_bench.py", line 1028, in <module>
    sys.exit(main())
  File "D:\Strata\tools\strata_bench.py", line 989, in main
    pre = collect_machine(base, key, cfg, a.gpu)
  File "D:\Strata\tools\strata_bench.py", line 639, in collect_machine
    "strata_version": project_version(), "strata_commit": git_commit(),
  File "D:\Strata\tools\strata_bench.py", line 564, in project_version
    m = re.search(r"project\(strata VERSION ([\d.]+)", (ROOT / "CMakeLists.txt").read_text())
  File "C:\Users\...\lib\pathlib.py", line 1135, in read_text
    return f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal multibyte sequence

CMakeLists.txt starts with the UTF-8 BOM EF BB BF; 0xbf at offset 2 is the third BOM byte. Note it leaves the server it started behind, and the process exits with a traceback rather than a message.

setup.py:4649 reads the same file with encoding="utf-8":

m = re.search(r"project\(strata VERSION ([\d.]+)", (ROOT / "CMakeLists.txt").read_text(encoding="utf-8"))

so this looks like a strata_bench.py omission rather than an intentional locale dependency. Other read_text() calls in the file that read repository files are likely to hit the same thing on those systems.

Workaround (no source change needed): run with UTF-8 mode on.

set PYTHONUTF8=1
BENCH.bat

Verified: the suite then runs to completion (420 s) and writes a normal report.

Suggested fix: pass encoding="utf-8" at that call (and audit the other read_text() calls in the file), or read with errors="replace" — the value only needs to match project(strata VERSION x.y.z).

Environment: Windows 11 Pro 10.0.26200, Python 3.10.11, Strata 0.1.44.1 (release engine). A benchmark report produced on this machine is in #2791, which mentions this bug.

Originally created by @Lithivm on GitHub (Oct 16, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2792 `tools/strata_bench.py:564` (`project_version`) reads `CMakeLists.txt` with `Path.read_text()` and **no `encoding=`**, so it decodes with the OS locale code page. On a Chinese or Japanese Windows (GBK / cp932) the file's UTF-8 BOM makes the read fail and `BENCH.bat` dies **before any measurement**: ``` $ python tools/strata_bench.py Starting strata-iq2_xs.json on port 8080 (loading takes 1-3 minutes; the PC may be slow meanwhile) ... still loading (2 s) ... Traceback (most recent call last): File "D:\Strata\tools\strata_bench.py", line 1028, in <module> sys.exit(main()) File "D:\Strata\tools\strata_bench.py", line 989, in main pre = collect_machine(base, key, cfg, a.gpu) File "D:\Strata\tools\strata_bench.py", line 639, in collect_machine "strata_version": project_version(), "strata_commit": git_commit(), File "D:\Strata\tools\strata_bench.py", line 564, in project_version m = re.search(r"project\(strata VERSION ([\d.]+)", (ROOT / "CMakeLists.txt").read_text()) File "C:\Users\...\lib\pathlib.py", line 1135, in read_text return f.read() UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal multibyte sequence ``` `CMakeLists.txt` starts with the UTF-8 BOM `EF BB BF`; `0xbf` at offset 2 is the third BOM byte. Note it leaves the server it started behind, and the process exits with a traceback rather than a message. `setup.py:4649` reads the same file with `encoding="utf-8"`: ```python m = re.search(r"project\(strata VERSION ([\d.]+)", (ROOT / "CMakeLists.txt").read_text(encoding="utf-8")) ``` so this looks like a `strata_bench.py` omission rather than an intentional locale dependency. Other `read_text()` calls in the file that read repository files are likely to hit the same thing on those systems. **Workaround** (no source change needed): run with UTF-8 mode on. ``` set PYTHONUTF8=1 BENCH.bat ``` Verified: the suite then runs to completion (420 s) and writes a normal report. **Suggested fix:** pass `encoding="utf-8"` at that call (and audit the other `read_text()` calls in the file), or read with `errors="replace"` — the value only needs to match `project(strata VERSION x.y.z)`. Environment: Windows 11 Pro 10.0.26200, Python 3.10.11, Strata 0.1.44.1 (release engine). A benchmark report produced on this machine is in #2791, which mentions this bug.
Author
Owner

@Niko1221 commented on GitHub (Oct 19, 2026):

Thanks for taking the time to report this.

We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6271261983 --> @Niko1221 commented on GitHub (Oct 19, 2026): Thanks for taking the time to report this. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
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
Niko1221/Strata#1120
No description provided.