I'm running an end-to-end test and I am not getting out what I put in.
Luckily the schema is pretty simple:
table MyMessage{ msg: [string]; }
In this array, I populate data like "ABC", "DEF", ...
Here is how I'm populating it:
===============
flaatbuffers::FlatBufferBuilder fbb;
std::vector<Flatbuffers::Offset<flatbuffers::String>> msgs_;
for(auto & element: std_strings){
auto fb_str = fbb.CreateString(element); <<<<==== A
msgs_.push_back(fb_str);
}
auto msgs = fbb.CreateVector(msgs_);
MyMessageBuilder e(fbb);
e.add_msgs(msgs);
auto inner_event = e.Finish();
...
===============
I step through this code in the debugger inside the for loop as well as near the end, I can see that what is being passed into the CreateString method (line A) is the string "ABC"
At the end, I expect to see "ABC" inside the fbb object (with inner_event showing an offset). However, what I actually see is gibberish. I expect the first three bytes to be 'A', 'B', 'C', perhaps a null terminator, then garbage afterwards. I don't see "ABC" at all (or anything it encodes into).
Naturally if something is wrong at this step, converting from raw bytes back to FB is still going to show garbage. Any ideas?