Issues / #2499
#2499 [Bug]: BENCH.bat / strata_bench.py crashes on Windows with a non-UTF-8 locale (UnicodeDecodeError reading CMakeLists.txt)
open · @hasifumi · 0 comments · View on GitHub
BenchmarksNVIDIA / CUDAWindowsLinux
Description
### What happened
`BENCH.bat` (`tools/strata_bench.py`) stops right after it finds the server on Windows with a Japanese locale (ANSI code page cp932). It never runs the suite:
```
Using the Strata server already running at http://127.0.0.1:8080.
Traceback (most recent call last):
File "<strata>\tools\strata_bench.py", line 1028, in <module>
sys.exit(main())
File "<strata>\tools\strata_bench.py", line 989, in main
pre = collect_machine(base, key, cfg, a.gpu)
File "<strata>\tools\strata_bench.py", line 639, in collect_machine
"strata_version": project_version(), "strata_commit": git_commit(),
File "<strata>\tools\strata_bench.py", line 564, in project_version
m = re.search(r"project\(strata VERSION ([\d.]+)", (ROOT / "CMakeLists.txt").read_text())
File "...\Python311\Lib\pathlib.py", line 1059, in read_text
return f.read()
UnicodeDecodeError: 'cp932' codec can't decode byte 0xef in position 0: illegal multibyte sequence
```
**Steps:** a v0.1.44.1 checkout on Windows 11 (Japanese), then `BENCH.bat` (or `.venv\Scripts\python.exe tools\strata_bench.py --url http://127.0.0.1:8080`).
**Cause:** `CMakeLists.txt` starts with a UTF-8 BOM (`ef bb bf`). `project_version()` calls `read_text()` with no encoding, so Python uses the locale's code page (cp932 here). The `except OSError` around it does not catch `UnicodeDecodeError` (a `ValueError`), so the whole run stops instead of reporting no version. Other non-UTF-8 code pages (cp936, cp949, cp1252...) should hit the same error. Linux and English Windows usually read UTF-8, which is probably why it has not shown up.
**Workaround:** `set PYTHONUTF8=1` before `BENCH.bat`. With it, the run finishes normally.
**Possible fix:** `(ROOT / "CMakeLists.txt").read_text(encoding="utf-8-sig")`, and/or `except (OSError, ValueError)` so that a version that cannot be read never stops the benchmark. I only checked this one call. The `/proc` reads in the same file are Linux-only, so they are not affected.
### Strata version, GPU, OS
Strata v0.1.44.1 (engine 0.1.44.1, CUDA 13.0 ready-made), RTX 5060 Ti 16 GB, Windows 11 Pro 26200 (Japanese), Python 3.11
### Engine log
Not relevant: the engine runs fine, and only the benchmark client fails.
Related on this site
Quick links to related pages.