Skip to content

[24364 & 24365] Add UBSan workflow and solve its errors (backport #6386)#6418

Closed
mergify[bot] wants to merge 1 commit into
2.6.xfrom
mergify/bp/2.6.x/pr-6386
Closed

[24364 & 24365] Add UBSan workflow and solve its errors (backport #6386)#6418
mergify[bot] wants to merge 1 commit into
2.6.xfrom
mergify/bp/2.6.x/pr-6386

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented Jun 3, 2026

Description

This PR adds a new workflow to Fast DDS: UBSan.

  • It adds a new valid value for -DSANITIZER=Undefined, which sets -fsanitize=undefined -fno-omit-frame-pointer -fsanitize=float-cast-overflow -fsanitize=float-divide-by-zero -fsanitize=bounds-strict
  • It fixes build of Tests with the new UBSan flags and solves one ODR warning
  • It adds a new regression test which must fail as it guarantees an UB error.
  • It fixes every UB error of the whole Fast DDS Suite. Most of the errors where test-related, although some minor fixes also applied to the library itself.

@Mergifyio backport 3.2.x 2.14.x 2.6.x

Related PRs

Merge after

Contributor Checklist

  • Commit messages follow the project guidelines.

  • The code follows the style guidelines of this project.

  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally

  • N/A: Any new/modified methods have been properly documented using Doxygen.

  • N/A: Any new configuration API has an equivalent XML API (with the corresponding XSD extension)

  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.

  • Changes are API compatible.

  • N/A: New feature has been added to the versions.md file (if applicable).

  • N/A: New feature has been documented/Current behavior is correctly described in the documentation.

  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • If this is a critical bug fix, backports to the critical-only supported branches have been requested.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

This is an automatic backport of pull request #6386 done by [Mergify](https://mergify.com).

* Refs #24364: Add UBSan workflow

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Add CMake Undefined Behavior option

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix building of tests with UBSan

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Compliance with ODR enum type in tests

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Regression Test Malicious Data

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Review - Meta file

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Ensure no duplicates originate in UBSAN report due to addresses

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Avoid calling memcmp with empty payloads

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in TimedEvent ctor

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in SampleLostStatus due to overflow

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in CDRMessage

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in statistics::DomainParticipant

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in ParticipantTests magically

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in UserListenerTests due to downcast

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in PoolConfig due to overflow

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in DataWriterTests magically

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in TCPv4Test due to wrong type cast

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in Security tests with SharedSecretHandle

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in Log Options

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in MonitorServiceTests

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Skip false positive of sqlite3.c

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix mac/windows build

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in DataReader/Writer blackbox tests

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in Latency tests

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in StatisticsTests magically

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in RTPSStatisticsTests magically

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #24365: Fix UB in SecurityManager

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

---------

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
(cherry picked from commit 25a43a7)

# Conflicts:
#	CMakeLists.txt
#	include/fastdds/statistics/dds/domain/DomainParticipant.hpp
#	src/cpp/fastdds/domain/DomainParticipantFactory.cpp
#	src/cpp/fastdds/publisher/DataWriterImpl.cpp
#	src/cpp/fastdds/subscriber/DataReaderImpl.cpp
#	src/cpp/rtps/common/SerializedPayload.cpp
#	src/cpp/rtps/history/PoolConfig.h
#	src/cpp/statistics/fastdds/domain/DomainParticipant.cpp
#	test/blackbox/common/BlackboxTestsSecurity.cpp
#	test/blackbox/common/DDSBlackboxTestsDataReader.cpp
#	test/blackbox/common/DDSBlackboxTestsDataWriter.cpp
#	test/blackbox/common/DDSBlackboxTestsMonitorService.cpp
#	test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp
#	test/blackbox/common/DDSBlackboxTestsPropertyQos.cpp
#	test/blackbox/common/RTPSBlackboxTestsReader.cpp
#	test/blackbox/common/RTPSBlackboxTestsWriter.cpp
#	test/mock/rtps/PublisherHistory/fastdds/publisher/DataWriterHistory.hpp
#	test/mock/rtps/TimedEvent/fastdds/rtps/resources/TimedEvent.h
#	test/unittest/dds/participant/ParticipantTests.cpp
#	test/unittest/dds/publisher/DataWriterTests.cpp
#	test/unittest/dds/status/ListenerTests.cpp
#	test/unittest/rtps/discovery/CMakeLists.txt
#	test/unittest/security/authentication/CMakeLists.txt
#	test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp
#	test/unittest/statistics/dds/StatisticsQosTests.cpp
#	test/unittest/statistics/rtps/CMakeLists.txt
#	test/unittest/statistics/rtps/RTPSStatisticsTests.cpp
#	test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp
#	test/unittest/transport/TCPv4Tests.cpp
@mergify mergify Bot added the conflicts Backport PR wich git cherry pick failed label Jun 3, 2026
@mergify
Copy link
Copy Markdown
Contributor Author

mergify Bot commented Jun 3, 2026

Cherry-pick of 25a43a7 has failed:

On branch mergify/bp/2.6.x/pr-6386
Your branch is up to date with 'origin/2.6.x'.

You are currently cherry-picking commit 25a43a7c3.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   .github/workflows/config/ubsan.meta
	modified:   .github/workflows/reusable-sanitizers-ci.yml
	modified:   .github/workflows/sanitizers-ci.yml
	modified:   .github/workflows/utils/log_parser.py
	modified:   include/fastdds/rtps/messages/CDRMessage.hpp
	modified:   include/fastdds/rtps/resources/TimedEvent.h
	modified:   include/fastdds/rtps/security/logging/LogOptions.h
	modified:   src/cpp/rtps/resources/TimedEvent.cpp
	modified:   src/cpp/rtps/security/SecurityManager.cpp
	modified:   test/blackbox/common/BlackboxTestsDeadlineQos.cpp
	modified:   test/blackbox/common/BlackboxTestsDiscovery.cpp
	modified:   test/blackbox/common/BlackboxTestsLifespanQoS.cpp
	modified:   test/blackbox/common/BlackboxTestsLivelinessQos.cpp
	modified:   test/blackbox/common/BlackboxTestsNetworkConf.cpp
	modified:   test/blackbox/common/BlackboxTestsPubSubBasic.cpp
	modified:   test/blackbox/common/BlackboxTestsPubSubFragments.cpp
	modified:   test/blackbox/common/BlackboxTestsPubSubHistory.cpp
	modified:   test/blackbox/common/BlackboxTestsRealtimeAllocations.cpp
	modified:   test/blackbox/common/BlackboxTestsTransportTCP.cpp
	modified:   test/blackbox/common/BlackboxTestsTransportUDP.cpp
	modified:   test/blackbox/common/BlackboxTestsVolatile.cpp
	modified:   test/blackbox/common/DDSBlackboxTestsListeners.cpp
	modified:   test/blackbox/common/DDSBlackboxTestsPersistence.cpp
	modified:   test/blackbox/common/DDSBlackboxTestsPersistenceGuid.cpp
	modified:   test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp
	modified:   test/blackbox/common/DDSBlackboxTestsUserDataQos.cpp
	modified:   test/blackbox/common/RTPSBlackboxTestsBasic.cpp
	modified:   test/blackbox/common/RTPSBlackboxTestsDiscovery.cpp
	modified:   test/blackbox/common/RTPSBlackboxTestsPersistence.cpp
	modified:   test/blackbox/common/RTPSBlackboxTestsPersistenceGuid.cpp
	modified:   test/blackbox/common/RTPSBlackboxTestsPools.cpp
	modified:   test/blackbox/common/RTPSBlackboxTestsVolatile.cpp
	new file:   test/mock/rtps/SharedSecretHandle/rtps/security/common/SharedSecretHandle.h
	modified:   test/performance/latency/LatencyTestPublisher.cpp
	modified:   test/unittest/rtps/writer/CMakeLists.txt
	modified:   test/unittest/security/cryptography/CMakeLists.txt
	modified:   test/unittest/statistics/dds/StatisticsDomainParticipantMockTests.cpp
	modified:   test/unittest/transport/CMakeLists.txt

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	both modified:   CMakeLists.txt
	both modified:   include/fastdds/statistics/dds/domain/DomainParticipant.hpp
	both modified:   src/cpp/fastdds/domain/DomainParticipantFactory.cpp
	both modified:   src/cpp/fastdds/publisher/DataWriterImpl.cpp
	both modified:   src/cpp/fastdds/subscriber/DataReaderImpl.cpp
	deleted by us:   src/cpp/rtps/common/SerializedPayload.cpp
	both modified:   src/cpp/rtps/history/PoolConfig.h
	both modified:   src/cpp/statistics/fastdds/domain/DomainParticipant.cpp
	both modified:   test/blackbox/common/BlackboxTestsSecurity.cpp
	both modified:   test/blackbox/common/DDSBlackboxTestsDataReader.cpp
	both modified:   test/blackbox/common/DDSBlackboxTestsDataWriter.cpp
	deleted by us:   test/blackbox/common/DDSBlackboxTestsMonitorService.cpp
	deleted by us:   test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp
	deleted by us:   test/blackbox/common/DDSBlackboxTestsPropertyQos.cpp
	deleted by us:   test/blackbox/common/RTPSBlackboxTestsReader.cpp
	deleted by us:   test/blackbox/common/RTPSBlackboxTestsWriter.cpp
	both modified:   test/mock/rtps/PublisherHistory/fastdds/publisher/DataWriterHistory.hpp
	both modified:   test/mock/rtps/TimedEvent/fastdds/rtps/resources/TimedEvent.h
	both modified:   test/unittest/dds/participant/ParticipantTests.cpp
	both modified:   test/unittest/dds/publisher/DataWriterTests.cpp
	both modified:   test/unittest/dds/status/ListenerTests.cpp
	both modified:   test/unittest/rtps/discovery/CMakeLists.txt
	both modified:   test/unittest/security/authentication/CMakeLists.txt
	deleted by us:   test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp
	both modified:   test/unittest/statistics/dds/StatisticsQosTests.cpp
	both modified:   test/unittest/statistics/rtps/CMakeLists.txt
	both modified:   test/unittest/statistics/rtps/RTPSStatisticsTests.cpp
	deleted by us:   test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp
	both modified:   test/unittest/transport/TCPv4Tests.cpp

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@MiguelCompany MiguelCompany deleted the mergify/bp/2.6.x/pr-6386 branch June 3, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts Backport PR wich git cherry pick failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants