Description
test_hazelcast_queue-cpp.txt### Summary
Deserializing an empty string using in.read<std::string>()
in Hazelcast C++ client version 5.2.5 causes a debug assertion failure. The crash occurs internally within the Hazelcast client when the string being read was originally serialized as an empty value (""
). This happens in debug builds on MSVC.
Environment
- Hazelcast C++ client version: 5.2.5
- Hazelcast Server version: Not relevant to the issue
- Operating system: Windows 10 / Windows 11
- Compiler: MSVC 2019 or MSVC 2022
- Build type: Debug
Steps to Reproduce
- Define a struct with a
char[]
field (e.g.,jobRequestUUID[51]
). - Initialize the struct using
memset
, leaving the string field empty. - Push the struct into a Hazelcast queue using
out.write(...)
. - Pop it using
in.read<std::string>()
. - Observe that the debug build crashes during deserialization.
Expected Behavior
Empty strings should be safely deserialized by in.read<std::string>()
without triggering a runtime assertion or crash.
Actual Behavior
Deserializing an empty string using in.read<std::string>()
causes a debug assertion failure inside the Hazelcast C++ client. The issue appears to be related to STL string handling in debug builds when the string length is zero.
Minimal Reproduction
The issue can be reproduced using the attached file:
test_hazelcast_queue-cpp.txt
This file defines a minimal struct and queue wrapper, then performs a push and pop where the string field is left empty. The deserialization step crashes consistently in MSVC debug builds.
Workaround
Avoid writing empty strings directly by substituting a space " "
as a placeholder, and clearing it on read:
// write
out.write(object.jobRequestUUID[0] ? object.jobRequestUUID : " ");
// read
std::string uuid = in.read<std::string>();
if (uuid == " ") uuid.clear();
Let me know if further details or trace output is needed.