Skip to content

Initial sanitizer configurations#1

Open
RSingh1511 wants to merge 2 commits intoeclipse-score:mainfrom
RSingh1511:rs/swp-245137
Open

Initial sanitizer configurations#1
RSingh1511 wants to merge 2 commits intoeclipse-score:mainfrom
RSingh1511:rs/swp-245137

Conversation

@RSingh1511
Copy link

No description provided.

Signed-off-by: rahul.singh <rahul.sa.singh@partner.bmwgroup.com>
@RSingh1511 RSingh1511 marked this pull request as draft March 3, 2026 15:00
Signed-off-by: rahul.singh <rahul.sa.singh@partner.bmwgroup.com>
@RSingh1511 RSingh1511 marked this pull request as ready for review March 4, 2026 04:07
@RSingh1511 RSingh1511 requested a review from FScholPer March 4, 2026 04:08
jobs:
test-sanitizers:
name: Validate sanitizer configs
runs-on: ubuntu-latest
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using latest? this can easily break our workflows in case it gets upgraded

EXPECT_EQ(counter.load(), 4000);
}

// Test for undefined behavior detection (UBSan)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is highly misleading. the below test does not contain any UB hence, how shall it help for verifying UB detection? better adjust the comment

EXPECT_EQ(vec[4], 5);
}

// Test that allocates memory (for ASan/LSan validation)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about

Suggested change
// Test that allocates memory (for ASan/LSan validation)
// Memory allocation test that should pass with all sanitizers

?

Comment on lines +21 to +22
bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.2.2")
bazel_dep(name = "score_bazel_platforms", version = "0.0.4")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these two required here? Where are they used actually?

Comment on lines +54 to +57
- `--config=asan` - AddressSanitizer (memory errors, buffer overflows)
- `--config=tsan` - ThreadSanitizer (data races, deadlocks)
- `--config=ubsan` - UndefinedBehaviorSanitizer (undefined behavior)
- `--config=lsan` - LeakSanitizer (memory leaks)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer alphabetical sorting instead?

Suggested change
- `--config=asan` - AddressSanitizer (memory errors, buffer overflows)
- `--config=tsan` - ThreadSanitizer (data races, deadlocks)
- `--config=ubsan` - UndefinedBehaviorSanitizer (undefined behavior)
- `--config=lsan` - LeakSanitizer (memory leaks)
- `--config=asan` - AddressSanitizer (memory errors, buffer overflows)
- `--config=lsan` - LeakSanitizer (memory leaks)
- `--config=tsan` - ThreadSanitizer (data races, deadlocks)
- `--config=ubsan` - UndefinedBehaviorSanitizer (undefined behavior)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about preferring plural here? would be more appropriate in my eyes since it makes clear that it will contain multiple sanitizer configs

i.e. sanitizers/sanitizers.bazelrc

# *******************************************************************************

# ASan + UBSan + LSan (Combined - recommended for most testing)
test:asan_ubsan_lsan --compilation_mode=dbg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not use dbg compliation mode. this would potentially enable code which is not part of the actual production code and hence you would potentially run into different code paths. just omit that everywhere since such compilation flags must come from the toolchain which defines the respective sanitizer features.
also see https://github.com/eclipse-score/communication/blob/main/quality/sanitizer/sanitizer.bazelrc#L20-L30 for further reference which flags we require for sanitizer configs

Comment on lines +25 to +27
test:tsan --compilation_mode=dbg
test:tsan --features=tsan
test:tsan --platform_suffix=tsan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and also for all the other configs:

Suggested change
test:tsan --compilation_mode=dbg
test:tsan --features=tsan
test:tsan --platform_suffix=tsan
build:tsan --features=tsan
build:tsan --platform_suffix=tsan

only the runtime options should get added as test config, the others are build configs!

Comment on lines +20 to +22
test:asan_ubsan_lsan --test_env=ASAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:detect_leaks=1:halt_on_error=1:allocator_may_return_null=1
test:asan_ubsan_lsan --test_env=UBSAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:print_stacktrace=1:halt_on_error=1
test:asan_ubsan_lsan --test_env=LSAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:halt_on_error=1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

such runtime options should get extracted into a single place and then reused here instead

Suggested change
test:asan_ubsan_lsan --test_env=ASAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:detect_leaks=1:halt_on_error=1:allocator_may_return_null=1
test:asan_ubsan_lsan --test_env=UBSAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:print_stacktrace=1:halt_on_error=1
test:asan_ubsan_lsan --test_env=LSAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:halt_on_error=1
test:_asan_runtime_options --test_env=ASAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:detect_leaks=1:halt_on_error=1:allocator_may_return_null=1
test:_asan_runtime_options --test_env=LSAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:halt_on_error=1
test:_ubsan_runtime_options --test_env=UBSAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:print_stacktrace=1:halt_on_error=1
<...>
test:asan_ubsan_lsan --config=_asan_runtime_options
test:asan_ubsan_lsan --config=_lsan_runtime_options
test:asan_ubsan_lsan --config=_ubsan_runtime_options
<...>
test:asan --config=_asan_runtime_options

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and please use the following runtime options instead:

test:_asan_runtime_options --test_env=ASAN_OPTIONS="exitcode=55 allow_addr2line=1 halt_on_error=1 print_stats=1 verbosity=1 allocator_may_return_null=1 check_initialization_order=1 detect_leaks=1 detect_stack_use_after_return=1 strict_string_checks=1"
test:_lsan_runtime_options --test_env=LSAN_OPTIONS="exitcode=55 allow_addr2line=1 halt_on_error=1 print_stats=1 verbosity=1"
test:_ubsan_runtime_options --test_env=UBSAN_OPTIONS="exitcode=55 allow_addr2line=1 halt_on_error=1 print_stacktrace=1 verbosity=1"
test:_tsan_runtime_options --test_env=TSAN_OPTIONS="exitcode=55 allow_addr2line=1 halt_on_error=1 print_stats=1 verbosity=1 detect_deadlocks=1 second_deadlock_stack=1"

- name: Test with ${{ matrix.config }}
working-directory: tests
run: |
bazel test --config=${{ matrix.config }} //:sample_test --verbose_failures
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not

Suggested change
bazel test --config=${{ matrix.config }} //:sample_test --verbose_failures
bazel test --config=${{ matrix.config }} //... --verbose_failures

?
since there will be further unit tests in this repo soon


module(
name = "score_cpp_policies",
version = "0.0.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please set the version to 0.0.0 here? The workflow in the S-CORE bazel registry is taking care of generating a patch when a release is picked.

@@ -0,0 +1,13 @@
Copyright 2026 Contributors to the Eclipse Foundation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the entire license text here and remove .md extension. You can copy it,for example for here: https://github.com/eclipse-score/module_template/blob/main/LICENSE

General guideline: https://www.eclipse.org/projects/handbook/#legaldoc-license


The [Eclipse Safe Open Vehicle Core (S-CORE)](https://projects.eclipse.org/projects/automotive.score) project develops an open-source core stack for Software Defined Vehicles (SDVs). This repository centralizes the shared C++ quality tool policies (sanitizers, clang-tidy, clang-format) that S-CORE modules reuse to maintain consistent, safety-focused defaults.

Project communication happens via the [score-dev mailing list](https://accounts.eclipse.org/mailing-list/score-dev), GitHub issues and pull requests, and the [Eclipse SCORE chatroom](https://chat.eclipse.org/#/room/#automotive.score:matrix.eclipse.org).
Copy link
Member

@4og 4og Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the statement coming from? S-CORE is not using Eclipse matrix chat for communication, but Slack instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants