Skip to content

Fix ov::Any string conversion for windows#35714

Open
rasapala wants to merge 1 commit intoopenvinotoolkit:masterfrom
rasapala:fix_string_handling
Open

Fix ov::Any string conversion for windows#35714
rasapala wants to merge 1 commit intoopenvinotoolkit:masterfrom
rasapala:fix_string_handling

Conversation

@rasapala
Copy link
Copy Markdown

@rasapala rasapala commented May 7, 2026

Details:

Fix unsafe type conversion in CPU plugin property handling

Fixes a potential crash caused by forcing numeric ov::Any values to
std::string through iostream conversion, which is unstable on Windows.

The CPU plugin's Config::readProperties unconditionally converts incoming
plugin properties to std::string before parsing, triggering unsafe iostream
type conversions when clients pass numeric types (int64_t, int) for
NUM_STREAMS or similar numeric properties.

This causes:

  • Unsafe iostream-based conversion path in ov::Any.asstd::string()
  • Possible memory corruption or segfault on Windows
  • Crashes in openvinotoolkit/openvino#XXXXX

Fix: Check the actual ov::Any type before conversion. Use native casts
for numeric types (int64_t, int) and only use iostream conversion path
for true string values.

Safe path is: numeric input -> std::to_string -> string -> parse
Unsafe path was: numeric input -> iostream conversion -> corrupted string -> crash

Fixes clients that pass:

  • {"NUM_STREAMS": 4} as ov::Any(int64_t(4))
  • {"NUM_STREAMS": 4} as ov::Any(int(4))
  • {"num_requests": 8} as ov::Any(int64_t(8))

Changes:

  • ov::num_streams handling: type-aware conversion
  • ov::hint::num_requests handling: type-aware conversion

Tickets:

  • None

AI Assistance:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: CPU OpenVINO CPU plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant