Skip to content

Commit abee55f

Browse files
cferreiragonzmergify[bot]
authored andcommitted
Add UBSan workflow and solve its errors (#6386)
* 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: # include/fastdds/statistics/dds/domain/DomainParticipant.hpp # src/cpp/fastdds/domain/DomainParticipantFactory.cpp # src/cpp/rtps/common/SerializedPayload.cpp # src/cpp/rtps/history/PoolConfig.h # src/cpp/statistics/fastdds/domain/DomainParticipant.cpp # test/blackbox/common/DDSBlackboxTestsDataReader.cpp # test/blackbox/common/DDSBlackboxTestsDataWriter.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
1 parent f76ca8a commit abee55f

67 files changed

Lines changed: 3674 additions & 161 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
names:
2+
fastdds:
3+
cmake-args:
4+
- -DNO_TLS=OFF
5+
- -DSECURITY=ON
6+
- -DFASTDDS_STATISTICS=ON
7+
- -DSANITIZER=Undefined
8+
- -DCOMPILE_WARNING_AS_ERROR=ON
9+
- -DEPROSIMA_BUILD_TESTS=ON
10+
- -DRTPS_API_TESTS=ON
11+
- -DFASTDDS_PIM_API_TESTS=ON
12+
- -DPERFORMANCE_TESTS=ON
13+
googletest-distribution:
14+
cmake-args:
15+
- -Dgtest_force_shared_crt=ON
16+
- -DBUILD_SHARED_LIBS=ON
17+
- -DBUILD_GMOCK=ON

.github/workflows/reusable-sanitizers-ci.yml

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
description: 'Run Thread Sanitizer job for Fast DDS'
2020
required: false
2121
type: boolean
22+
run_ubsan_fastdds:
23+
description: 'Run Undefined Behavior Sanitizer job for Fast DDS'
24+
required: false
25+
type: boolean
2226
colcon_build_args:
2327
description: 'Optional colcon build arguments'
2428
required: false
@@ -547,3 +551,189 @@ jobs:
547551
run: |
548552
Write-Host ${{ steps.report_summary.outcome }}
549553
exit 1
554+
555+
ubsan_fastdds_build:
556+
if: ${{ inputs.run_ubsan_fastdds == true }}
557+
runs-on: ubuntu-24.04
558+
steps:
559+
- name: Free disk space
560+
uses: eProsima/eProsima-CI/ubuntu/free_disk_space@v0
561+
562+
- name: Sync eProsima/Fast-DDS repository
563+
uses: eProsima/eProsima-CI/external/checkout@v0
564+
with:
565+
path: src/fastdds
566+
submodules: true
567+
ref: ${{ inputs.fastdds_ref }}
568+
569+
- name: Install Fix Python version
570+
uses: eProsima/eProsima-CI/external/setup-python@v0
571+
with:
572+
python-version: '3.11'
573+
574+
- name: Get minimum supported version of CMake
575+
uses: eProsima/eProsima-CI/external/get-cmake@v0
576+
with:
577+
cmakeVersion: '3.28.6'
578+
579+
- name: Install apt packages
580+
uses: eProsima/eProsima-CI/ubuntu/install_apt_packages@v0
581+
with:
582+
packages: curl grep libasio-dev libtinyxml2-dev python3 python3-pip software-properties-common wget
583+
584+
- name: Install colcon
585+
uses: eProsima/eProsima-CI/ubuntu/install_colcon@v0
586+
587+
- name: Install Python dependencies
588+
uses: eProsima/eProsima-CI/ubuntu/install_python_packages@v0
589+
with:
590+
packages: vcstool xmlschema
591+
592+
- name: Setup CCache
593+
uses: eProsima/eProsima-CI/external/setup-ccache-action@v0
594+
if: ${{ !always() }}
595+
with:
596+
api_token: ${{ secrets.GITHUB_TOKEN }}
597+
598+
- name: Get Fast CDR branch
599+
id: get_fastcdr_branch
600+
uses: eProsima/eProsima-CI/ubuntu/get_related_branch_from_repo@v0
601+
with:
602+
remote_repository: eProsima/Fast-CDR
603+
fallback_branch: ${{ inputs.fastcdr_ref }}
604+
605+
- name: Download Fast CDR
606+
uses: eProsima/eProsima-CI/external/checkout@v0
607+
with:
608+
repository: eProsima/Fast-CDR
609+
path: ${{ github.workspace }}/src/fastcdr
610+
ref: ${{ steps.get_fastcdr_branch.outputs.deduced_branch }}
611+
612+
- name: Fetch Fast DDS dependencies
613+
uses: eProsima/eProsima-CI/ubuntu/vcs_import@v0
614+
with:
615+
vcs_repos_file: ${{ github.workspace }}/src/fastdds/fastdds.repos
616+
destination_workspace: src
617+
skip_existing: 'true'
618+
619+
- name: Fetch Fast DDS CI dependencies
620+
uses: eProsima/eProsima-CI/ubuntu/vcs_import@v0
621+
with:
622+
vcs_repos_file: ${{ github.workspace }}/src/fastdds/.github/workflows/config/fastdds_test.repos
623+
destination_workspace: src
624+
skip_existing: 'true'
625+
626+
- name: Show .meta file
627+
id: show_meta
628+
run: |
629+
cat ${{ github.workspace }}/src/fastdds/.github/workflows/config/ubsan.meta
630+
631+
- name: Colcon build
632+
continue-on-error: false
633+
uses: eProsima/eProsima-CI/ubuntu/colcon_build@v0
634+
with:
635+
colcon_meta_file: ${{ github.workspace }}/src/fastdds/.github/workflows/config/ubsan.meta
636+
colcon_build_args: ${{ inputs.colcon_build_args }}
637+
cmake_args: ${{ inputs.cmake_args }}
638+
cmake_args_default: ''
639+
cmake_build_type: 'Debug'
640+
workspace: ${{ github.workspace }}
641+
workspace_dependencies: ''
642+
643+
- name: Pack workspace preserving permissions
644+
shell: bash
645+
run: |
646+
tar -C "${{ github.workspace }}" -cpf "${{ runner.temp }}/ubsan_build_${{ inputs.label }}.tar" .
647+
648+
- name: Upload build artifacts
649+
uses: eProsima/eProsima-CI/external/upload-artifact@v0
650+
with:
651+
name: build_artifacts_fastdds_ubsan_${{ inputs.label }}
652+
path: ${{ runner.temp }}/ubsan_build_${{ inputs.label }}.tar
653+
654+
ubsan_fastdds_test:
655+
if: ${{ inputs.run_ubsan_fastdds == true }}
656+
needs: ubsan_fastdds_build
657+
runs-on: ubuntu-24.04
658+
env:
659+
UBSAN_OPTIONS: halt_on_error=1:abort_on_error=1:print_stacktrace=1
660+
steps:
661+
- name: Free disk space
662+
uses: eProsima/eProsima-CI/ubuntu/free_disk_space@v0
663+
664+
- name: Download build artifact
665+
uses: eProsima/eProsima-CI/external/download-artifact@v0
666+
with:
667+
name: build_artifacts_fastdds_ubsan_${{ inputs.label }}
668+
path: ${{ runner.temp }}
669+
670+
- name: Unpack workspace preserving permissions
671+
shell: bash
672+
run: |
673+
tar -C "${{ github.workspace }}" -xpf "${{ runner.temp }}/ubsan_build_${{ inputs.label }}.tar"
674+
675+
- name: Install Fix Python version
676+
uses: eProsima/eProsima-CI/external/setup-python@v0
677+
with:
678+
python-version: '3.11'
679+
680+
- name: Get minimum supported version of CMake
681+
uses: eProsima/eProsima-CI/external/get-cmake@v0
682+
with:
683+
cmakeVersion: '3.28.6'
684+
685+
- name: Install apt packages
686+
uses: eProsima/eProsima-CI/ubuntu/install_apt_packages@v0
687+
with:
688+
packages: curl grep libasio-dev libtinyxml2-dev python3 python3-pip software-properties-common wget
689+
690+
- name: Install colcon
691+
uses: eProsima/eProsima-CI/ubuntu/install_colcon@v0
692+
693+
- name: Install Python dependencies
694+
uses: eProsima/eProsima-CI/ubuntu/install_python_packages@v0
695+
with:
696+
packages: setuptools gcovr tomark xmltodict jsondiff pandas psutil
697+
698+
- name: Set up hosts file for DNS testing
699+
run: |
700+
sudo echo "" | sudo tee -a /etc/hosts
701+
sudo echo "127.0.0.1 localhost.test" | sudo tee -a /etc/hosts
702+
sudo echo "::1 localhost.test" | sudo tee -a /etc/hosts
703+
sudo echo "154.56.134.194 www.eprosima.com.test" | sudo tee -a /etc/hosts
704+
sudo echo "216.58.215.164 www.acme.com.test" | sudo tee -a /etc/hosts
705+
sudo echo "2a00:1450:400e:803::2004 www.acme.com.test" | sudo tee -a /etc/hosts
706+
sudo echo "140.82.121.4 www.foo.com.test" | sudo tee -a /etc/hosts
707+
sudo echo "140.82.121.3 www.foo.com.test" | sudo tee -a /etc/hosts
708+
sudo echo "ff1e::ffff:efff:1 acme.org.test" | sudo tee -a /etc/hosts
709+
710+
- name: Colcon test
711+
id: test
712+
continue-on-error: true
713+
uses: eProsima/eProsima-CI/ubuntu/colcon_test@v0
714+
with:
715+
colcon_args_default: ''
716+
colcon_test_args: ${{ inputs.colcon_test_args }}
717+
colcon_test_args_default: '--event-handlers=console_direct+ --return-code-on-test-failure'
718+
ctest_args: ${{ inputs.ctest_args }}
719+
ctest_args_default: '--timeout 300 --label-exclude "xfail"'
720+
packages_names: fastdds
721+
workspace: ${{ github.workspace }}
722+
workspace_dependencies: ''
723+
test_report_artifact: ${{ format('test_report_{0}_{1}', inputs.label, github.job) }}
724+
725+
- name: Report sanitizer errors
726+
run: |
727+
# UBSan finding header lines look like:
728+
# <file>:<line>:<col>: runtime error: <description>
729+
# Filter on ": runtime error:" so we keep one line per finding (the header)
730+
bash src/fastdds/.github/workflows/utils/specific_errors_filter.sh \
731+
": runtime error:" \
732+
log/latest_test/fastdds/stdout_stderr.log \
733+
_tmp_specific_error_file.log
734+
735+
python3 src/fastdds/.github/workflows/utils/log_parser.py \
736+
--log-file log/latest_test/fastdds/stdout_stderr.log \
737+
--specific-error-file _tmp_specific_error_file.log \
738+
--output-file $GITHUB_STEP_SUMMARY \
739+
--sanitizer ubsan

.github/workflows/sanitizers-ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
description: 'Run Thread Sanitizer job for Fast DDS'
2020
required: false
2121
type: boolean
22+
run_ubsan_fastdds:
23+
description: 'Run Undefined Behavior Sanitizer job for Fast DDS'
24+
required: false
25+
type: boolean
2226
colcon_build_args:
2327
description: 'Optional colcon build arguments'
2428
required: false
@@ -69,6 +73,7 @@ jobs:
6973
run_asan_fastdds: ${{ ((inputs.run_asan_fastdds == true) && true) || github.event_name == 'pull_request' }}
7074
run_asan_discovery_server: ${{ ((inputs.run_asan_discovery_server == true) && true) || github.event_name == 'pull_request' }}
7175
run_tsan_fastdds: ${{ ((inputs.run_tsan_fastdds == true) && true) || github.event_name == 'pull_request' }}
76+
run_ubsan_fastdds: ${{ ((inputs.run_ubsan_fastdds == true) && true) || github.event_name == 'pull_request' }}
7277
colcon_build_args: ${{ inputs.colcon_build_args || '' }}
7378
colcon_test_args: ${{ inputs.colcon_test_args || '' }}
7479
cmake_args: ${{ inputs.cmake_args || '' }}

0 commit comments

Comments
 (0)