Enable entity exception on DataWriter

8 posts / 0 new
Last post
Offline
Last seen: 2 years 9 months ago
Joined: 09/08/2020
Posts: 26
Enable entity exception on DataWriter

I'm trying to create a DataWriter for a custom topic and RTI is throwing an "Enable entity" exception.  I rebuilt in debug and exception occurs on highlighted line:

    dds::topic::Topic<UMAA::MM::ManageMissionPlan::MissionPlanReportType> topic(participant, "MissionPlanReportType Topic");

    dds::pub::Publisher publisher(participant);

    dds::pub::DataWriter<UMAA::MM::ManageMissionPlan::MissionPlanReportType> writer(publisher, topic);

Stack trace shows the following (below).  retcode is DDS_RETCODE_ERROR(1).  Debugger also shows an error popup: "Could not open "__cxa_throw" for reading.  Either the file does not exist or you do not have permissions to open it."

Stack trace

Any ideas what might be causing this issue?  Just before this I had a similar project working (just a different topic being published).

Offline
Last seen: 2 months 2 days ago
Joined: 04/02/2013
Posts: 196

The full message should be printed in the console and included the exception what() method, which you can catch as a std::exception.

Offline
Last seen: 2 years 9 months ago
Joined: 09/08/2020
Posts: 26

I'm capturing the full error, which is just "Enable entity":

    try {
        run_example(arguments.domain_id, arguments.sample_count);
    } catch (const std::exception& ex) {
        // This will catch DDS exceptions
        std::cerr << "Exception in run_example(): " << ex.what()
                  << std::endl;
        return EXIT_FAILURE;
    }

Debugger on the exception:

This line in TDataWriter appears to be the issue:

  DataWriter(
      const dds::pub::Publisher& pub,
      const dds::topic::Topic<T>& the_topic)
      : dds::core::TEntity<DELEGATE<T> >(new DELEGATE<T>(pub, the_topic))
   {
      this->delegate()->remember_reference(this->delegate());
   }

Where delegate() is (Reference.hpp):

    DELEGATE_REF_T& delegate() OMG_NOEXCEPT
    {
        return impl_;
    }

The impl_ that gets returned looks valid on first glance.  But the remember_reference() part doesn't work.  I'm unable to step into it and see what's going on.

 

Offline
Last seen: 2 years 9 months ago
Joined: 09/08/2020
Posts: 26

Potentially interesting note: If I step into this->delegate()->remember_reference(this->delegate()); the debugger appears to loop a lot on that line.  Even if I hold down my Step Into shortcut key F11 it keeps looping over and and over.  Then when I finally continue with F5 the exception throws.

Offline
Last seen: 2 years 9 months ago
Joined: 09/08/2020
Posts: 26

I've also been reading into the "Could not open "__cxa_throw" for reading" error.  One site mentioned incompatible compilers could have an impact.  https://monoinfinito.wordpress.com/series/exception-handling-in-c/

I'm compiling my app with g++ 4.7.2 20121015.  I could not find RTI libs with the same g++ version so I'm using x64Linux2.6gcc4.4.5.  Despite the different g++ versions for the libs I've been able to create a DataWriter successfully for several other custom IDL topic types.  So doesn't seem like different g++'s is the issue necessarily.

Offline
Last seen: 2 months 2 days ago
Joined: 04/02/2013
Posts: 196

This is a failure in the DDS_Entity_enable() function, and could be due to multiple reasons. It should be printing the full error in the console.

You shouldn't need to open the source of __cxa_throw, that's just the low-level compiler-generated code that throws the exception and is totally unrelated to the error in DDS.

Alex

Offline
Last seen: 2 years 9 months ago
Joined: 09/08/2020
Posts: 26

This topic IDL is unique from the previous ones (which published correctly) in that it contains a sequence<CustomType> field.

If I change CustomType to something else (like a string) the message starts to publish.

Inside CustomType is included a sequence<AnotherCustomType>.  I'm wondering if this "sequence of sequences" pattern is crashing the DataWriter (original IDL contains a sequence of CustomType's, where each CustomType is a sequence of AnotherCustomType's).

I tried changing AnotherCustomType to something else (like a string), and the original topic still failed to publish.  Having nested sequences appears to be a problem.  Maybe related to this earlier post?

Offline
Last seen: 2 years 9 months ago
Joined: 09/08/2020
Posts: 26

Root cause of this issue was having 3+ nested sequences (causes memory allocation errors).  Temporary fix is hardcoding a maximum element count for each sequence (e.g. sequence<string,10>).  I think the long term fix is setting a maximum sequence length in the DataWriter.  Looking into this related documentation:

https://community.rti.com/examples/using-sequences

To illustrate: Publishing this topic worked:

MyTopic.idl

Foo.idl

Bar.idl

#include "Foo.idl"

 

struct MyTopic

{

        sequence<Foo> fooStuff;

};

 

#include "Bar.idl"

 

struct Foo

{

        sequence<Bar> barThings;

        string parentText;

};

 

struct Bar

{

        string stuff;

};

 

However adding a 3rd nested sequence in Bar.idl resulted in the exception:

MyTopic.idl

Foo.idl

Bar.idl

#include "Foo.idl"

 

struct MyTopic

{

        sequence<Foo> fooStuff;

};

 

#include "Bar.idl"

 

struct Foo

{

        sequence<Bar> barThings;

        string parentText;

};

 

struct Bar

{

        sequence<string> seq;

};

Related error snippet:
RTIOsapiHeap_allocateBufferAligned:!malloc size exceeds heap (4027158016 > 2147483647)
REDAFastBufferPool_growEmptyPoolEA: !allocate buffer of 4027158016 bytes
REDAFastBufferPool_newWithNotification:!create fast buffer pool buffers
PRESTypePluginDefaultEndpointData_createWriterPool:!create writer buffer pool
PRESPsService_enableLocalEndpointWithCursor:failed to attach endpoint to typePlugin
PRESPsService_enableLocalEndpoint:!enable local endpoint
DDSDataWriter_impl::createI:ERROR: Failed to auto-enable entity
create_datawriter error