-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
OpenVINO Version
2025.1.0
Operating System
Windows System
Device used for inference
CPU
Framework
ONNX
Model used
No response
Issue description
openvino/src/inference/src/cpp/core.cpp
Lines 31 to 40 in 8f9ab4c
const auto ov_library_path = ov::util::get_ov_lib_path(); | |
// plugins xml can be found in either: | |
// 1. openvino-X.Y.Z relative to libopenvino.so folder | |
std::ostringstream str; | |
str << "openvino-" << OPENVINO_VERSION_MAJOR << "." << OPENVINO_VERSION_MINOR << "." << OPENVINO_VERSION_PATCH; | |
const auto sub_folder = str.str(); | |
// register plugins from default openvino-<openvino version>/plugins.xml config | |
auto xmlConfigFileDefault = ov::util::path_join({ov_library_path, sub_folder, xml_file_name}).string(); |
The above code get ov_library_path
string from ov::util::get_ov_lib_path()
, which is utf-8 encoding, and then pass it to ov::util::path_join
in which the string will be used to construct a std::filesystem::path
object, but unfortunately, the std::filesystem::path
's default construct function will decode string as locale encoding, which may cause a crash if the string contains non-ASCII characters.
wstring_to_string
will convert wide string to utf-8 string on windows:
openvino/src/common/util/src/file_util.cpp
Lines 360 to 366 in 85ca5fa
std::string ov::util::get_ov_lib_path() { | |
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT | |
return ov::util::wstring_to_string(ov::util::get_ov_lib_path_w()); | |
#else | |
return get_ov_library_path_a(); | |
#endif | |
} |
path_join
receive args as list of ov::util::Path
, and ov::util::Path
is an alias of std::filesystem::path
:
openvino/src/common/util/src/file_util.cpp
Lines 104 to 105 in 85ca5fa
template <class Container = std::initializer_list<ov::util::Path>> | |
ov::util::Path path_join(Container&& paths) { |
using Path = std::filesystem::path; |
Step-by-step reproduction
put the openvino library in a path with non-ASCII characters (e.g, C:\Users\Public\새 폴더3\my_app\openvino.dll
) and call the normal inference API. (Note that the Windows system encoding should not be utf-8).
Fix Proposal
may be we can construct the Path
object explicitly according the OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
macro with std::filesystem::u8path
:
const auto ov_library_path_str = ov::util::get_ov_lib_path();
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
auto ov_library_path = std::filesystem::u8path(ov_library_path_str);
#else
auto ov_library_path = std::filesystem::path(ov_library_path_str);
#endif
// plugins xml can be found in either:
// 1. openvino-X.Y.Z relative to libopenvino.so folder
std::ostringstream str;
str << "openvino-" << OPENVINO_VERSION_MAJOR << "." << OPENVINO_VERSION_MINOR << "." << OPENVINO_VERSION_PATCH;
const auto sub_folder = str.str();
// register plugins from default openvino-<openvino version>/plugins.xml config
auto xmlConfigFileDefault = ov::util::path_join({ov_library_path, sub_folder, xml_file_name}).string();
Maybe a better idea is to pass the std::filesystem::path
object directly between all interfaces.
Relevant log output
Issue submission checklist
- I'm reporting an issue. It's not a question.
- I checked the problem with the documentation, FAQ, open issues, Stack Overflow, etc., and have not found a solution.
- There is reproducer code and related data files such as images, videos, models, etc.