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

Segmentation Fault arises when initializing a publisher in a constructor #4018

Closed
1 task done
CuiiGen opened this issue Nov 14, 2023 · 2 comments
Closed
1 task done
Assignees
Labels
in progress Issue or PR which is being reviewed need more info Issue that requires more info from contributor

Comments

@CuiiGen
Copy link

CuiiGen commented Nov 14, 2023

Is there an already existing issue for this?

  • I have searched the existing issues

Expected behavior

We define a class, and it has only one private member variable mypub, an instance of the Class MsgPublisher.
We then call its initialization method mypub.init() in the constructor of MsgPublisher.

Current behavior

Segmentation Fault arises when initializing that publisher.

Steps to reproduce

Here is an example to reproduce this issue.
TestDDS - 20231114.zip

mkdir build
cd build
cmake ..
run ./TestDDS

Here is the information from the call stack when running the program in debug mode.
The last three lines indicate where the error occurs in my code.

std::vector<eprosima::fastrtps::rtps::Locator_t, std::allocator<eprosima::fastrtps::rtps::Locator_t> >::size(const std::vector<eprosima::fastrtps::rtps::Locator_t, std::allocator<eprosima::fastrtps::rtps::Locator_t> > * const this) (\usr\include\c++\11\bits\stl_vector.h:919)
std::vector<eprosima::fastrtps::rtps::Locator_t, std::allocator<eprosima::fastrtps::rtps::Locator_t> >::vector(std::vector<eprosima::fastrtps::rtps::Locator_t, std::allocator<eprosima::fastrtps::rtps::Locator_t> > * const this, const std::vector<eprosima::fastrtps::rtps::Locator_t, std::allocator<eprosima::fastrtps::rtps::Locator_t> > & __x) (\usr\include\c++\11\bits\stl_vector.h:555)
eprosima::fastdds::rtps::LocatorList::LocatorList(eprosima::fastdds::rtps::LocatorList * const this, const eprosima::fastdds::rtps::LocatorList & list) (\usr\local\include\fastdds\rtps\common\LocatorList.hpp:114)
eprosima::fastdds::rtps::RemoteServerAttributes::RemoteServerAttributes(eprosima::fastdds::rtps::RemoteServerAttributes * const this) (\usr\local\include\fastdds\rtps\attributes\ServerAttributes.h:47)
__gnu_cxx::new_allocator<std::_List_node<eprosima::fastdds::rtps::RemoteServerAttributes> >::construct<eprosima::fastdds::rtps::RemoteServerAttributes, eprosima::fastdds::rtps::RemoteServerAttributes const&>(__gnu_cxx::new_allocator<std::_List_node<eprosima::fastdds::rtps::RemoteServerAttributes> > * const this, eprosima::fastdds::rtps::RemoteServerAttributes * __p) (\usr\include\c++\11\ext\new_allocator.h:162)
std::allocator_traits<std::allocator<std::_List_node<eprosima::fastdds::rtps::RemoteServerAttributes> > >::construct<eprosima::fastdds::rtps::RemoteServerAttributes, eprosima::fastdds::rtps::RemoteServerAttributes const&>(std::allocator_traits<std::allocator<std::_List_node<eprosima::fastdds::rtps::RemoteServerAttributes> > >::allocator_type & __a, eprosima::fastdds::rtps::RemoteServerAttributes * __p) (\usr\include\c++\11\bits\alloc_traits.h:516)
std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> >::_M_create_node<eprosima::fastdds::rtps::RemoteServerAttributes const&>(std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> > * const this) (\usr\include\c++\11\bits\stl_list.h:638)
std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> >::_M_insert<eprosima::fastdds::rtps::RemoteServerAttributes const&>(std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> > * const this, std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> >::iterator __position) (\usr\include\c++\11\bits\stl_list.h:1912)
std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> >::emplace_back<eprosima::fastdds::rtps::RemoteServerAttributes const&>(std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> > * const this) (\usr\include\c++\11\bits\stl_list.h:1228)
std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> >::_M_initialize_dispatch<std::_List_const_iterator<eprosima::fastdds::rtps::RemoteServerAttributes> >(std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> > * const this, std::_List_const_iterator<eprosima::fastdds::rtps::RemoteServerAttributes> __first, std::_List_const_iterator<eprosima::fastdds::rtps::RemoteServerAttributes> __last) (\usr\include\c++\11\bits\stl_list.h:1841)
std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> >::list(std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> > * const this, const std::__cxx11::list<eprosima::fastdds::rtps::RemoteServerAttributes, std::allocator<eprosima::fastdds::rtps::RemoteServerAttributes> > & __x) (\usr\include\c++\11\bits\stl_list.h:739)
eprosima::fastrtps::rtps::DiscoverySettings::DiscoverySettings(eprosima::fastrtps::rtps::DiscoverySettings * const this) (\usr\local\include\fastdds\rtps\attributes\RTPSParticipantAttributes.h:233)
eprosima::fastrtps::rtps::BuiltinAttributes::BuiltinAttributes(eprosima::fastrtps::rtps::BuiltinAttributes * const this) (\usr\local\include\fastdds\rtps\attributes\RTPSParticipantAttributes.h:372)
eprosima::fastdds::dds::WireProtocolConfigQos::WireProtocolConfigQos(eprosima::fastdds::dds::WireProtocolConfigQos * const this) (\usr\local\include\fastdds\dds\core\policy\QosPolicies.hpp:2655)
eprosima::fastdds::dds::DomainParticipantQos::DomainParticipantQos(eprosima::fastdds::dds::DomainParticipantQos const&) (Unknown Source:0)
eprosima::fastdds::dds::DomainParticipantFactory::DomainParticipantFactory() (Unknown Source:0)
eprosima::fastdds::dds::DomainParticipantFactory::get_instance() (Unknown Source:0)
MsgSubscriber::init(MsgSubscriber * const this) (\home\linux\projects\TestDDS\DDS\MsgSubscriber.cxx:63)
TestDDS__RecvData_real_T::TestDDS__RecvData_real_T(TestDDS__RecvData_real_T * const this) (\home\linux\projects\TestDDS\ert_main.cpp:13)
__static_initialization_and_destruction_0(int __initialize_p, int __priority) (\home\linux\projects\TestDDS\ert_main.cpp:32)

Here is a screenshot.

image

Fast DDS version/commit

v2.12.0

Platform/Architecture

Ubuntu Focal 20.04 amd64

Transport layer

UDPv4

Additional context

No response

XML configuration file

No response

Relevant log output

No response

Network traffic capture

No response

@CuiiGen CuiiGen added the triage Issue pending classification label Nov 14, 2023
@Mario-DL Mario-DL self-assigned this Dec 19, 2023
@Mario-DL Mario-DL added in progress Issue or PR which is being reviewed and removed triage Issue pending classification labels Dec 19, 2023
@Mario-DL
Copy link
Member

Hi @CuiiGen,

Thanks for the report and code sample. I could reproduce the problem. It seems to me that the problem has to do with the static variable initialization which may be unpredictable in early initialization and different across platforms. I suggest making the InputRecvData_arg, OutputSendData_arg and TestDDS_Obj non static as well as creating them within main, passing a capture of TestDDS_Obj by reference to the periodic event handler.
Let us know if that helps.

@Mario-DL Mario-DL added the need more info Issue that requires more info from contributor label Dec 19, 2023
@Mario-DL
Copy link
Member

According to our CONTRIBUTING.md guidelines, I am closing this issue due to inactivity. Please, feel free to reopen it if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress Issue or PR which is being reviewed need more info Issue that requires more info from contributor
Projects
None yet
Development

No branches or pull requests

2 participants