Fast-DDS icon indicating copy to clipboard operation
Fast-DDS copied to clipboard

DataWriter write data crash frequently with segment fault when using ContentFilteredTopic

Open GalaxyDreamWings opened this issue 9 months ago • 3 comments

Is there an already existing issue for this?

  • [X] I have searched the existing issues

Expected behavior

use ContentFilteredTopic and set filter expression to receive required data

Current behavior

The operation seem to be valid and the application can run normally for a while but would crash occasionally or even frequently with segment fault. But if DataReader doesn't use ContentFilteredTopic, everything is well. The call stack is shown below:

libfastrtps. so. 2.14! void eprosima::fastdds::dds::ContentFilterInfo::cdr_serialize <eprosima: :fastdds: :dds: :ReaderFilterCollection: :update_filter_info (eprosima: :fastdds : :dds : :DataWriterFilteredChange&, eprosima::fastrtps: :rtps: :SampleIdentity const&) const:: {lambda (unsigned long,unsigned char*)#1}>(eprosima: :fastrtps: :rtps: :SerializedPayload_t&, unsigned long, eprosima: :fastdds : : dds : :ReaderFilterCollection::update_filter_info (eprosima: :fastdds : :dds : :DataWriterFilteredChange&, eprosima::fastrtps::rtps: :SampleIdentity const&) const:: {lambda(unsigned long,unsigned char*)#1}) (Unknown Source:0) libfastrtps. so. 2.14! eprosima::fastdds : : dds : :DataWriterImpl : :perforn_create_new_change (eprosima: :fastrtps::rtps::ChangeKind_t, void*, eprosima::fastrtps: :rtps : :WriteParams&, eprosima: :fastrtps: :rtps : : InstanceHandle_t const&) (Unknown Source:0)* libfastrtps.so. 2.14! eprosima::fastdds: :dds: :DataWriterImpl: :create_new_change_with_params (eprosima: :fastrtps: :rtps::ChangeKind_t, void*, eprosima::fastrtps::rtps::WriteParams&) (Unknown Source:0) libfastrtps. so. 2. 14! eprosima: :fastdds : :dds : :DataWriterImpl : :create_new_change (eprosima::fastrtps: :rtps::ChangeKind_t, void*) (Unknown Source:0)* libfastrtps. so. 2. 14! eprosima: :fastdds: :dds : :DataWriterImpl: :write(void*)(Unknown Source:0)

Steps to reproduce

The IDL file:

struct DMsg
{
    unsigned long actorId;
    sequence<char> msgContent;
};

And the filter expression:

string expression = "actorId = 0x12345678";
vector<string> parameters;
setTopicFilter(ESMsgId::eServerState,expression,parameters);

void CFastDDSManager::setTopicFilter(ESMsgId smsgId, std::string expression, std::vector<std::string> parameters)
{
    auto iter_map_topic = m_map_topic.find(smsgId);
    if (iter_map_topic != m_map_topic.end()) {
        if(iter_map_topic->second.pFilteredTopic == nullptr) {
            ContentFilteredTopic* pFilteredTopic = m_pParticipant->create_contentfilteredtopic(
                    iter_map_topic->second.pTopic->get_name() + "_Filtered", iter_map_topic->second.pTopic, expression,
                    parameters);

            iter_map_topic->second.pFilteredTopic = pFilteredTopic;
        }else {
            iter_map_topic->second.pFilteredTopic->set_filter_expression(expression,parameters);
        }
    }
}

relevant code for write data:

if(msg.getLength() != 0) {
        std::vector<char> vec_msgContent(msg.getContent(),msg.getContent() + msg.getLength());
        DMsg dmsg;
        dmsg.msgContent(vec_msgContent);
        dmsg.actorId(0x12345678);
        return iter_map_topic->second.writer->write(&dmsg);
}

Fast DDS version/commit

2.14.x

commit 74b2a74ef339816b6fef448efa676042a339b2e3 (HEAD -> master, origin/master, origin/HEAD, origin/2.14.x) Author: Des glaneurs [email protected] Date: Tue Mar 12 17:34:01 2024 +0900

Platform/Architecture

Ubuntu Focal 20.04 arm64, Other. Please specify in Additional context section.

Transport layer

Default configuration, UDPv4 & SHM

Additional context

Galaxy Kylin OS (Linux) aarch64 run in docker

XML configuration file

No response

Relevant log output

No response

Network traffic capture

No response

GalaxyDreamWings avatar May 30 '24 15:05 GalaxyDreamWings