fix(trace): preserve Unicode output paths on Windows #7599

Merged
THEMANnt merged 2 commits from upstream-pr/7599 into main 2026-11-08 08:17:33 +00:00
THEMANnt commented 2026-10-18 16:33:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-18T16:33:27Z.


What

On Windows, setting APS5_TRACE_DIR to a directory containing characters such as ™ or Japanese text can throw filesystem error: Cannot convert character sequence: Illegal byte sequence when trace output is initialized. The narrow environment-variable value is passed through a locale-dependent filesystem conversion.

Read this path with _wgetenv on Windows and construct it from the native wide string. Put the shared directory selection in TraceFile::Directory, used by both interval summaries and captured traces. POSIX continues to use getenv; an unset variable still selects ..

The Windows regression checks unset and ASCII settings, preserves a Unicode path, and writes both gzip trace and JSONL summary files there. No title-specific handling is added.

Tested

Current revision 4593f50e7, rebased onto upstream main db73af350, Windows 11 Pro build 26200, supported MinGW-w64 GCC 15.2, Release:

  • agc_performance_trace and agc_profile_output: both build and pass on this branch, including the Unicode directory regression. Conventions against target upstream/main and whitespace pass.
  • The required conventions run against stale fork origin/main reports the pre-existing APS5_CPU_FLIP_IN_ORDER environment-documentation error and upstream debt warnings; none of that code is changed here.
  • Reproduced the #7080 test-file merge conflict, then separated the new standard-library includes and the Directory() call from its benchmark additions. The Unicode test body and production fix are unchanged by this follow-up.
  • Fresh changed-file audit of all 694 open PRs found only #7080 sharing these files (excluding this PR itself). This branch adds no files or exports. The unchanged tools/pr_overlap.py --branch fix/trace-unicode-paths, using authenticated API transport and that exhaustive candidate set, reports No overlap with open pull requests.
  • This branch merges cleanly with #7080 head 88f818410218ca4aa117d850354a50f0a1fe4b62. A separate local integration build succeeds; agc_profile_output and param_json_parser pass. Its expanded agc_performance_trace test fails with St13__ios_failure ... has no unwind data. A control containing main + #7080 without this PR reproduces the same failure. The combined suite is therefore not claimed green; that exception-handling failure is separate from this branch's resolved merge overlap.

Earlier validation at d7738226d remains applicable to the unchanged Unicode fix: the narrow-conversion negative control fails; the wide-path test passed five repeated runs; the runtime libs target and four focused trace/registration tests built and passed. An independent Windows/Linux validation is recorded in wachi35676's comment. Full runtime libraries, registration GPU tests and Linux/macOS were not rerun for this test-layout-only follow-up. No performance claim.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 616.92, Windows 11 Pro build 26200
  • AI-assisted: yes (OpenAI Codex; reviewed and tested locally)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4910822762 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7599). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-18T16:33:27Z. --- ### What On Windows, setting `APS5_TRACE_DIR` to a directory containing characters such as `™` or Japanese text can throw `filesystem error: Cannot convert character sequence: Illegal byte sequence` when trace output is initialized. The narrow environment-variable value is passed through a locale-dependent filesystem conversion. Read this path with `_wgetenv` on Windows and construct it from the native wide string. Put the shared directory selection in `TraceFile::Directory`, used by both interval summaries and captured traces. POSIX continues to use `getenv`; an unset variable still selects `.`. The Windows regression checks unset and ASCII settings, preserves a Unicode path, and writes both gzip trace and JSONL summary files there. No title-specific handling is added. ### Tested Current revision `4593f50e7`, rebased onto upstream main `db73af350`, Windows 11 Pro build 26200, supported MinGW-w64 GCC 15.2, Release: - `agc_performance_trace` and `agc_profile_output`: both build and pass on this branch, including the Unicode directory regression. Conventions against target `upstream/main` and whitespace pass. - The required conventions run against stale fork `origin/main` reports the pre-existing `APS5_CPU_FLIP_IN_ORDER` environment-documentation error and upstream debt warnings; none of that code is changed here. - Reproduced the #7080 test-file merge conflict, then separated the new standard-library includes and the `Directory()` call from its benchmark additions. The Unicode test body and production fix are unchanged by this follow-up. - Fresh changed-file audit of all 694 open PRs found only #7080 sharing these files (excluding this PR itself). This branch adds no files or exports. The unchanged `tools/pr_overlap.py --branch fix/trace-unicode-paths`, using authenticated API transport and that exhaustive candidate set, reports `No overlap with open pull requests.` - This branch merges cleanly with #7080 head `88f818410218ca4aa117d850354a50f0a1fe4b62`. A separate local integration build succeeds; `agc_profile_output` and `param_json_parser` pass. Its expanded `agc_performance_trace` test fails with `St13__ios_failure ... has no unwind data`. A control containing main + #7080 without this PR reproduces the same failure. The combined suite is therefore not claimed green; that exception-handling failure is separate from this branch's resolved merge overlap. Earlier validation at `d7738226d` remains applicable to the unchanged Unicode fix: the narrow-conversion negative control fails; the wide-path test passed five repeated runs; the runtime `libs` target and four focused trace/registration tests built and passed. An independent Windows/Linux validation is recorded in [wachi35676's comment](https://github.com/boykopovar/AnyPS5/pull/7599#issuecomment-6256917347). Full runtime libraries, registration GPU tests and Linux/macOS were not rerun for this test-layout-only follow-up. No performance claim. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 616.92, Windows 11 Pro build 26200 - [x] AI-assisted: yes (OpenAI Codex; reviewed and tested locally)
wachi35676 commented 2026-10-19 00:13:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T00:13:03Z.


Checked at d7738226d with the variable inherited from the parent process rather than set in-process (PowerShell, ACP 1252, the same libstdc++). Comparing getenv→path with this PR's _wgetenv→path:

  • ASCII: both work.
  • café, tm™ (in cp1252): the narrow form throws Cannot convert character sequence: Illegal byte sequence.
  • 日本語, жу, emoji😀 (not in cp1252; the last is a surrogate pair): getenv returns ?, and the narrow form fails with cannot create directories: Invalid argument [...\???].

_wgetenv creates the right directory and writes the file in all six cases.

Tests:

  • agc_performance_trace, agc_profile_output and both agc_driver_registration_trace tests pass on Windows (GCC 15.2).
  • With the narrow getenv put back into TraceFile::Directory, agc_performance_trace fails with the conversion error.
  • On Linux (gcc 13.3), agc_performance_trace and agc_profile_output pass.

The same narrow getenv→path pattern exists for APS5_DUMP_SUBMITS in SubmissionCapture.cpp:104, if a follow-up is wanted.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6256917347 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7599#issuecomment-6256917347). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-19T00:13:03Z. --- Checked at `d7738226d` with the variable inherited from the parent process rather than set in-process (PowerShell, ACP 1252, the same libstdc++). Comparing `getenv`→`path` with this PR's `_wgetenv`→`path`: - **ASCII:** both work. - **`café`, `tm™` (in cp1252):** the narrow form throws `Cannot convert character sequence: Illegal byte sequence`. - **`日本語`, `жу`, `emoji😀`** (not in cp1252; the last is a surrogate pair): `getenv` returns `?`, and the narrow form fails with `cannot create directories: Invalid argument [...\???]`. `_wgetenv` creates the right directory and writes the file in all six cases. Tests: - `agc_performance_trace`, `agc_profile_output` and both `agc_driver_registration_trace` tests pass on Windows (GCC 15.2). - With the narrow `getenv` put back into `TraceFile::Directory`, `agc_performance_trace` fails with the conversion error. - On Linux (gcc 13.3), `agc_performance_trace` and `agc_profile_output` pass. The same narrow `getenv`→`path` pattern exists for `APS5_DUMP_SUBMITS` in `SubmissionCapture.cpp:104`, if a follow-up is wanted. AI-assisted: yes (Claude Code); results above were run on this machine.
MarcZX10 commented 2026-10-21 23:38:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T23:38:29Z.

Review: APPROVED


The Windows path is read as wide text and kept in std::filesystem::path without a locale-dependent narrow conversion; the POSIX path remains unchanged. The new test covers unset, ASCII and Unicode values and verifies both summary and gzip output. The reported Windows negative control and independent cross-platform test results support the fix; the current conventions, eligibility and report checks pass. I also reran tools/pr_overlap.py against the current open PR queue (1,105 PRs), and it reports no overlap. I did not run the product tests locally. No blocking issue found; approved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607541953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7599#pullrequestreview-5607541953). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T23:38:29Z. **Review:** APPROVED --- The Windows path is read as wide text and kept in `std::filesystem::path` without a locale-dependent narrow conversion; the POSIX path remains unchanged. The new test covers unset, ASCII and Unicode values and verifies both summary and gzip output. The reported Windows negative control and independent cross-platform test results support the fix; the current conventions, eligibility and report checks pass. I also reran `tools/pr_overlap.py` against the current open PR queue (1,105 PRs), and it reports no overlap. I did not run the product tests locally. No blocking issue found; approved.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
boykopovar/AnyPS5!7599
No description provided.