Skip to content

Commit 25a43a7

Browse files
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>
1 parent 910ac99 commit 25a43a7

67 files changed

Lines changed: 1046 additions & 198 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
@@ -15,6 +15,10 @@ on:
1515
description: 'Run Thread Sanitizer job for Fast DDS'
1616
required: false
1717
type: boolean
18+
run_ubsan_fastdds:
19+
description: 'Run Undefined Behavior Sanitizer job for Fast DDS'
20+
required: false
21+
type: boolean
1822
colcon_build_args:
1923
description: 'Optional colcon build arguments'
2024
required: false
@@ -424,3 +428,189 @@ jobs:
424428
run: |
425429
Write-Host ${{ steps.report_summary.outcome }}
426430
exit 1
431+
432+
ubsan_fastdds_build:
433+
if: ${{ inputs.run_ubsan_fastdds == true }}
434+
runs-on: ubuntu-24.04
435+
steps:
436+
- name: Free disk space
437+
uses: eProsima/eProsima-CI/ubuntu/free_disk_space@v0
438+
439+
- name: Sync eProsima/Fast-DDS repository
440+
uses: eProsima/eProsima-CI/external/checkout@v0
441+
with:
442+
path: src/fastdds
443+
submodules: true
444+
ref: ${{ inputs.fastdds_ref }}
445+
446+
- name: Install Fix Python version
447+
uses: eProsima/eProsima-CI/external/setup-python@v0
448+
with:
449+
python-version: '3.11'
450+
451+
- name: Get minimum supported version of CMake
452+
uses: eProsima/eProsima-CI/external/get-cmake@v0
453+
with:
454+
cmakeVersion: '3.28.6'
455+
456+
- name: Install apt packages
457+
uses: eProsima/eProsima-CI/ubuntu/install_apt_packages@v0
458+
with:
459+
packages: curl grep libasio-dev libtinyxml2-dev python3 python3-pip software-properties-common wget
460+
461+
- name: Install colcon
462+
uses: eProsima/eProsima-CI/ubuntu/install_colcon@v0
463+
464+
- name: Install Python dependencies
465+
uses: eProsima/eProsima-CI/ubuntu/install_python_packages@v0
466+
with:
467+
packages: vcstool xmlschema
468+
469+
- name: Setup CCache
470+
uses: eProsima/eProsima-CI/external/setup-ccache-action@v0
471+
if: ${{ !always() }}
472+
with:
473+
api_token: ${{ secrets.GITHUB_TOKEN }}
474+
475+
- name: Get Fast CDR branch
476+
id: get_fastcdr_branch
477+
uses: eProsima/eProsima-CI/ubuntu/get_related_branch_from_repo@v0
478+
with:
479+
remote_repository: eProsima/Fast-CDR
480+
fallback_branch: ${{ inputs.fastcdr_ref }}
481+
482+
- name: Download Fast CDR
483+
uses: eProsima/eProsima-CI/external/checkout@v0
484+
with:
485+
repository: eProsima/Fast-CDR
486+
path: ${{ github.workspace }}/src/fastcdr
487+
ref: ${{ steps.get_fastcdr_branch.outputs.deduced_branch }}
488+
489+
- name: Fetch Fast DDS dependencies
490+
uses: eProsima/eProsima-CI/ubuntu/vcs_import@v0
491+
with:
492+
vcs_repos_file: ${{ github.workspace }}/src/fastdds/fastdds.repos
493+
destination_workspace: src
494+
skip_existing: 'true'
495+
496+
- name: Fetch Fast DDS CI dependencies
497+
uses: eProsima/eProsima-CI/ubuntu/vcs_import@v0
498+
with:
499+
vcs_repos_file: ${{ github.workspace }}/src/fastdds/.github/workflows/config/fastdds_test.repos
500+
destination_workspace: src
501+
skip_existing: 'true'
502+
503+
- name: Show .meta file
504+
id: show_meta
505+
run: |
506+
cat ${{ github.workspace }}/src/fastdds/.github/workflows/config/ubsan.meta
507+
508+
- name: Colcon build
509+
continue-on-error: false
510+
uses: eProsima/eProsima-CI/ubuntu/colcon_build@v0
511+
with:
512+
colcon_meta_file: ${{ github.workspace }}/src/fastdds/.github/workflows/config/ubsan.meta
513+
colcon_build_args: ${{ inputs.colcon_build_args }}
514+
cmake_args: ${{ inputs.cmake_args }}
515+
cmake_args_default: ''
516+
cmake_build_type: 'Debug'
517+
workspace: ${{ github.workspace }}
518+
workspace_dependencies: ''
519+
520+
- name: Pack workspace preserving permissions
521+
shell: bash
522+
run: |
523+
tar -C "${{ github.workspace }}" -cpf "${{ runner.temp }}/ubsan_build_${{ inputs.label }}.tar" .
524+
525+
- name: Upload build artifacts
526+
uses: eProsima/eProsima-CI/external/upload-artifact@v0
527+
with:
528+
name: build_artifacts_fastdds_ubsan_${{ inputs.label }}
529+
path: ${{ runner.temp }}/ubsan_build_${{ inputs.label }}.tar
530+
531+
ubsan_fastdds_test:
532+
if: ${{ inputs.run_ubsan_fastdds == true }}
533+
needs: ubsan_fastdds_build
534+
runs-on: ubuntu-24.04
535+
env:
536+
UBSAN_OPTIONS: halt_on_error=1:abort_on_error=1:print_stacktrace=1
537+
steps:
538+
- name: Free disk space
539+
uses: eProsima/eProsima-CI/ubuntu/free_disk_space@v0
540+
541+
- name: Download build artifact
542+
uses: eProsima/eProsima-CI/external/download-artifact@v0
543+
with:
544+
name: build_artifacts_fastdds_ubsan_${{ inputs.label }}
545+
path: ${{ runner.temp }}
546+
547+
- name: Unpack workspace preserving permissions
548+
shell: bash
549+
run: |
550+
tar -C "${{ github.workspace }}" -xpf "${{ runner.temp }}/ubsan_build_${{ inputs.label }}.tar"
551+
552+
- name: Install Fix Python version
553+
uses: eProsima/eProsima-CI/external/setup-python@v0
554+
with:
555+
python-version: '3.11'
556+
557+
- name: Get minimum supported version of CMake
558+
uses: eProsima/eProsima-CI/external/get-cmake@v0
559+
with:
560+
cmakeVersion: '3.28.6'
561+
562+
- name: Install apt packages
563+
uses: eProsima/eProsima-CI/ubuntu/install_apt_packages@v0
564+
with:
565+
packages: curl grep libasio-dev libtinyxml2-dev python3 python3-pip software-properties-common wget
566+
567+
- name: Install colcon
568+
uses: eProsima/eProsima-CI/ubuntu/install_colcon@v0
569+
570+
- name: Install Python dependencies
571+
uses: eProsima/eProsima-CI/ubuntu/install_python_packages@v0
572+
with:
573+
packages: setuptools gcovr tomark xmltodict jsondiff pandas psutil
574+
575+
- name: Set up hosts file for DNS testing
576+
run: |
577+
sudo echo "" | sudo tee -a /etc/hosts
578+
sudo echo "127.0.0.1 localhost.test" | sudo tee -a /etc/hosts
579+
sudo echo "::1 localhost.test" | sudo tee -a /etc/hosts
580+
sudo echo "154.56.134.194 www.eprosima.com.test" | sudo tee -a /etc/hosts
581+
sudo echo "216.58.215.164 www.acme.com.test" | sudo tee -a /etc/hosts
582+
sudo echo "2a00:1450:400e:803::2004 www.acme.com.test" | sudo tee -a /etc/hosts
583+
sudo echo "140.82.121.4 www.foo.com.test" | sudo tee -a /etc/hosts
584+
sudo echo "140.82.121.3 www.foo.com.test" | sudo tee -a /etc/hosts
585+
sudo echo "ff1e::ffff:efff:1 acme.org.test" | sudo tee -a /etc/hosts
586+
587+
- name: Colcon test
588+
id: test
589+
continue-on-error: true
590+
uses: eProsima/eProsima-CI/ubuntu/colcon_test@v0
591+
with:
592+
colcon_args_default: ''
593+
colcon_test_args: ${{ inputs.colcon_test_args }}
594+
colcon_test_args_default: '--event-handlers=console_direct+ --return-code-on-test-failure'
595+
ctest_args: ${{ inputs.ctest_args }}
596+
ctest_args_default: '--timeout 300 --label-exclude "xfail"'
597+
packages_names: fastdds
598+
workspace: ${{ github.workspace }}
599+
workspace_dependencies: ''
600+
test_report_artifact: ${{ format('test_report_{0}_{1}', inputs.label, github.job) }}
601+
602+
- name: Report sanitizer errors
603+
run: |
604+
# UBSan finding header lines look like:
605+
# <file>:<line>:<col>: runtime error: <description>
606+
# Filter on ": runtime error:" so we keep one line per finding (the header)
607+
bash src/fastdds/.github/workflows/utils/specific_errors_filter.sh \
608+
": runtime error:" \
609+
log/latest_test/fastdds/stdout_stderr.log \
610+
_tmp_specific_error_file.log
611+
612+
python3 src/fastdds/.github/workflows/utils/log_parser.py \
613+
--log-file log/latest_test/fastdds/stdout_stderr.log \
614+
--specific-error-file _tmp_specific_error_file.log \
615+
--output-file $GITHUB_STEP_SUMMARY \
616+
--sanitizer ubsan

.github/workflows/sanitizers-ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
description: 'Run Thread Sanitizer job for Fast DDS'
1616
required: false
1717
type: boolean
18+
run_ubsan_fastdds:
19+
description: 'Run Undefined Behavior Sanitizer job for Fast DDS'
20+
required: false
21+
type: boolean
1822
colcon_build_args:
1923
description: 'Optional colcon build arguments'
2024
required: false
@@ -59,6 +63,7 @@ jobs:
5963
label: ${{ inputs.label || 'fastdds-sanitizers-ci' }}
6064
run_asan_fastdds: ${{ ((inputs.run_asan_fastdds == true) && true) || github.event_name == 'pull_request' }}
6165
run_tsan_fastdds: ${{ ((inputs.run_tsan_fastdds == true) && true) || github.event_name == 'pull_request' }}
66+
run_ubsan_fastdds: ${{ ((inputs.run_ubsan_fastdds == true) && true) || github.event_name == 'pull_request' }}
6267
colcon_build_args: ${{ inputs.colcon_build_args || '' }}
6368
colcon_test_args: ${{ inputs.colcon_test_args || '' }}
6469
cmake_args: ${{ inputs.cmake_args || '' }}

0 commit comments

Comments
 (0)