Skip to content

Debug assertion failure in in.read<std::string>() when deserializing empty string (Hazelcast C++ 5.2.5) [API-2284] #1298

Open
@pooja-achievement

Description

@pooja-achievement

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

  1. Define a struct with a char[] field (e.g., jobRequestUUID[51]).
  2. Initialize the struct using memset, leaving the string field empty.
  3. Push the struct into a Hazelcast queue using out.write(...).
  4. Pop it using in.read<std::string>().
  5. 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.

Metadata

Metadata

Assignees

Labels

Source: Communityto-jiraUse to create a placeholder Jira issue in Jira APIs Project

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions