onnxruntime
3bb032e8 - Fix non-ASCII Unicode model path crash across session and provider code (#27724)

Commit
17 days ago
Fix non-ASCII Unicode model path crash across session and provider code (#27724) ### Description On Windows, `std::filesystem::path::string()` converts the internal UTF-16 representation to a narrow string using the system's active ANSI code page. When the path contains characters outside that code page (Japanese, Chinese, Korean, etc.), this throws std::system_error with 'No mapping for the Unicode character exists in the target multi-byte code page.' This affected both the core session telemetry logging (causing `InferenceSession::Initialize()` to fail) and execution provider code (OpenVINO, TensorRT, TensorRT RTX, QNN, MIGraphX) where model paths are converted for EPContext attributes and profiling. ### Motivation and Context Fix: Replace `.filename().string()` with `PathToUTF8String(.filename().native())` which uses `WideCharToMultiByte(CP_UTF8, ...)` and handles all Unicode characters correctly. This pattern is already used elsewhere in the codebase for path-to-string conversions. Note: Two remaining instances in Linux-only code (`cann_utils.cc`, `device_discovery.cc`) are left as-is since `.string()` is safe on Linux where paths are already narrow strings. Fixes microsoft/WindowsAppSDK#6173 --------- Co-authored-by: Sagar Bhure <sagarbhure@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Parents
Loading