I have a problem with a keyed type that has variable serialized key size.
register_instance can crash after a short key is seen first and a longer key is registered later. I managed to create a minimal repro that demonstrates the issue.
- CycloneDDS-CXX 11.0.1
- OS: Debian
IDL
module repro {
@final
struct KeyedSample {
@key string<255> id;
int32 value;
};
};
Minimal C++ program
#include <dds/dds.hpp>
#include <iostream>
#include <string>
#include "repro.hpp"
static repro::KeyedSample makeSample(const std::string& key, int32_t v) {
repro::KeyedSample s;
s.id(key);
s.value(v);
return s;
}
int main() {
dds::domain::DomainParticipant participant(0);
dds::topic::Topic<repro::KeyedSample> topic(participant, "myTopic");
dds::pub::Publisher publisher(participant);
dds::pub::DataWriter<repro::KeyedSample> writer(publisher, topic);
const std::string shortKey = "short";
const std::string longKey19 = "longkeyabcdefghijkl"; // 19 chars
const std::string longKey20 = "longkeyabcdefghijklm"; // 20 chars
writer.register_instance(makeSample(shortKey, 1));
std::cout << "1. Works" << std::endl;
writer.register_instance(makeSample(longKey19, 2));
std::cout << "2. Works" << std::endl;
writer.register_instance(makeSample(longKey20, 3)); // --> This call segfaults
std::cout << "Won't print" << std::endl;
return 0;
}
Steps to reproduce
- Generate type support from the IDL with
idlc.
- Build the repro program against CycloneDDS-CXX.
- Run the program.
Result
Can someone confirm that this program crashes with segmentation fault during register_instance after key length crosses boundary in this sequence?
Output:
1. Works
2. Works
Segmentation fault (core dumped)
I have a problem with a keyed type that has variable serialized key size.
register_instancecan crash after a short key is seen first and a longer key is registered later. I managed to create a minimal repro that demonstrates the issue.IDL
module repro { @final struct KeyedSample { @key string<255> id; int32 value; }; };Minimal C++ program
Steps to reproduce
idlc.Result
Can someone confirm that this program crashes with segmentation fault during
register_instanceafter key length crosses boundary in this sequence?Output: