diff --git a/include/fastdds/statistics/dds/domain/DomainParticipant.hpp b/include/fastdds/statistics/dds/domain/DomainParticipant.hpp index ee69c1cfd7c..e6286a18d2b 100644 --- a/include/fastdds/statistics/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/statistics/dds/domain/DomainParticipant.hpp @@ -26,9 +26,7 @@ #include #include #include -#include #include -#include #include #include @@ -49,13 +47,6 @@ class DomainParticipant : public eprosima::fastdds::dds::DomainParticipant { DomainParticipant() = delete; -protected: - - DomainParticipant( - const eprosima::fastdds::dds::StatusMask& mask); - - friend class eprosima::fastdds::dds::DomainParticipantFactory; - public: /** diff --git a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp index c93333e8203..711ac92caa4 100644 --- a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp @@ -39,10 +39,6 @@ #include #include -#ifdef FASTDDS_STATISTICS -#include -#endif // ifdef FASTDDS_STATISTICS - using namespace eprosima::fastdds::xmlparser; using eprosima::fastdds::rtps::RTPSDomain; @@ -161,13 +157,12 @@ DomainParticipant* DomainParticipantFactory::create_participant( const DomainParticipantQos& pqos = (&qos == &PARTICIPANT_QOS_DEFAULT) ? default_participant_qos_ : qos; -#ifndef FASTDDS_STATISTICS DomainParticipant* dom_part = new DomainParticipant(mask); +#ifndef FASTDDS_STATISTICS DomainParticipantImpl* dom_part_impl = new DomainParticipantImpl(dom_part, did, pqos, listener); #else - statistics::dds::DomainParticipant* dom_part = new statistics::dds::DomainParticipant(mask); - statistics::dds::DomainParticipantImpl* dom_part_impl = - new statistics::dds::DomainParticipantImpl(dom_part, did, pqos, listener); + statistics::dds::DomainParticipantImpl* dom_part_impl = new statistics::dds::DomainParticipantImpl(dom_part, did, + pqos, listener); #endif // FASTDDS_STATISTICS if (fastdds::rtps::GUID_t::unknown() != dom_part_impl->guid()) diff --git a/src/cpp/statistics/fastdds/domain/DomainParticipant.cpp b/src/cpp/statistics/fastdds/domain/DomainParticipant.cpp index 3ad872043cd..40834038f03 100644 --- a/src/cpp/statistics/fastdds/domain/DomainParticipant.cpp +++ b/src/cpp/statistics/fastdds/domain/DomainParticipant.cpp @@ -31,12 +31,6 @@ namespace fastdds { namespace statistics { namespace dds { -DomainParticipant::DomainParticipant( - const eprosima::fastdds::dds::StatusMask& mask) - : eprosima::fastdds::dds::DomainParticipant(mask) -{ -} - fastdds::dds::ReturnCode_t DomainParticipant::enable_statistics_datawriter( const std::string& topic_name, const eprosima::fastdds::dds::DataWriterQos& dwqos) @@ -82,7 +76,7 @@ DomainParticipant* DomainParticipant::narrow( eprosima::fastdds::dds::DomainParticipant* domain_participant) { #ifdef FASTDDS_STATISTICS - return static_cast(domain_participant); + return reinterpret_cast(domain_participant); #else (void)domain_participant; return nullptr; @@ -93,7 +87,7 @@ const DomainParticipant* DomainParticipant::narrow( const eprosima::fastdds::dds::DomainParticipant* domain_participant) { #ifdef FASTDDS_STATISTICS - return static_cast(domain_participant); + return reinterpret_cast(domain_participant); #else (void)domain_participant; return nullptr; diff --git a/test/blackbox/CMakeLists.txt b/test/blackbox/CMakeLists.txt index 6e6147b21ee..ebf61fe2bdb 100644 --- a/test/blackbox/CMakeLists.txt +++ b/test/blackbox/CMakeLists.txt @@ -143,6 +143,17 @@ set(DDS_BLACKBOXTESTS_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../../src/cpp/rtps/messages/CDRMessage.cpp ) +# These statistics tests narrow a base DomainParticipant to statistics::dds::DomainParticipant +# and call members on it. That is intentional UB (the object is never constructed as the derived +# type, to avoid emitting its vtable and breaking ABI), so disable the vptr (bad-downcast) check +# for just these translation units +if(SANITIZER STREQUAL "UNDEFINED") + set_source_files_properties( + ${CMAKE_CURRENT_SOURCE_DIR}/common/DDSBlackboxTestsStatistics.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/common/DDSBlackboxTestsMonitorService.cpp + PROPERTIES COMPILE_OPTIONS "-fno-sanitize=vptr") +endif() + # Prepare static discovery xml file for blackbox tests. string(RANDOM LENGTH 4 ALPHABET 0123456789 TOPIC_RANDOM_NUMBER) math(EXPR TOPIC_RANDOM_NUMBER "${TOPIC_RANDOM_NUMBER} + 0") # Remove extra leading 0s. diff --git a/test/unittest/statistics/dds/CMakeLists.txt b/test/unittest/statistics/dds/CMakeLists.txt index 06cdc5c5d69..008e23c2240 100644 --- a/test/unittest/statistics/dds/CMakeLists.txt +++ b/test/unittest/statistics/dds/CMakeLists.txt @@ -22,6 +22,19 @@ if(TINYXML2_INCLUDE_DIR) include_directories(${TINYXML2_INCLUDE_DIR}) endif(TINYXML2_INCLUDE_DIR) +# These tests narrow a base DomainParticipant to statistics::dds::DomainParticipant and call members +# on it. That is intentional UB (the object is never constructed as the derived type, to avoid +# emitting its vtable and breaking ABI), so disable the vptr (bad-downcast) check for just these +# translation units +if(SANITIZER STREQUAL "UNDEFINED") + set_source_files_properties( + StatisticsDomainParticipantTests.cpp + StatisticsQosTests.cpp + StatisticsDomainParticipantStatusQueryableTests.cpp + StatisticsDomainParticipantMockTests.cpp + PROPERTIES COMPILE_OPTIONS "-fno-sanitize=vptr") +endif() + ## StatisticsDomainParticipantTests set(STATISTICS_DOMAINPARTICIPANT_TESTS_SOURCE StatisticsDomainParticipantTests.cpp