Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion `!nested' failed. #8219

Open
palan1204 opened this issue Jan 18, 2024 · 0 comments
Open

Assertion `!nested' failed. #8219

palan1204 opened this issue Jan 18, 2024 · 0 comments

Comments

@palan1204
Copy link

I am getting Notnested assertion when i try to serialization of vector of vectors
Here is my serialization code Not sure what went wrong.

const auto bufferSize = static_cast<uint32_t>(bufferEnd - bufferStart);
flatbuffers::FlatBufferBuilder builder;
bool isSerialised = false;

try
{
    const AABMessageNewBaseTablesNotification& msg = dynamic_cast<const AABMessageNewBaseTablesNotification&>(message);
    
    // Move the creation of sub-objects above the FlatBufferBuilder construction
    std::vector<flatbuffers::Offset<AAB::UpdatedBDTList>> updatedBDTListVector;
    const auto& updatedBDTList = msg.GetUpdatedBDTList();
    
    for (const auto& pair : updatedBDTList)
    {
        auto TableList = VectorToFlatBufferVector(pair.second, builder);
        auto ServiceName  = builder.CreateString(pair.first);
        updatedBDTListVector.push_back(AAB::CreateUpdatedBDTList(builder, ServiceName, TableList));
    }
    
    AAB::AABMessageNewBaseDataTablesNotificationBuilder messageBuilder(builder);
    messageBuilder.add_type(msg.Type());
    messageBuilder.add_version(msg.Version());
    messageBuilder.add_updatedBDTList(builder.CreateVector(updatedBDTListVector));
    
    auto messageOffset = messageBuilder.Finish();
    builder.Finish(messageOffset);
    
    auto size = builder.GetSize();
    messageSize = size;
    
    if (size <= bufferSize) {
        auto span = builder.GetBufferPointer();  // Use GetBufferPointer instead of GetBufferSpan
        std::copy(span, span + size, bufferStart);
        isSerialised = (size != 0);
    }
}
catch (const std::bad_cast&)
{
}

builder.Clear();
return isSerialised;

Thank you for submitting an issue!

Please make sure you include the names of the affected language(s), compiler version(s), operating system version(s), and FlatBuffers version(s) in your issue title.

This helps us get the correct maintainers to look at your issue. Here are examples of good titles:

  • Crash when accessing FlatBuffer [C++, gcc 4.8, OS X, master]
  • Flatc converts a protobuf 'bytes' field to 'string' in fbs schema file [all languages, FlatBuffers 1.4]

Include other details as appropriate.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant