Skip to content

Type Sanitizer Implementation - #44

Merged
nradakovic merged 4 commits into
eclipse-score:mainfrom
armando-martins:ajfm_tysan_implementation
Sep 16, 2026
Merged

nradakovic merged 4 commits into
eclipse-score:mainfrom
armando-martins:ajfm_tysan_implementation

Conversation

@armando-martins

@armando-martins armando-martins commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Current concerns

  • TySan is a recent tool, and is still under development, and with that we have some concerns that should be address while implementing this new Sanitizer:
    • We update the LLVM version to 22.1.7, aligned with the rest of the score repos. This 22.1.7 version contains the new TySan, while the previous one (19.1.7) didn't.
    • To be able to use that LLVM version, we had also to bump the toolchains_llvm version to 1.8.0 (from 1.7.0)
  • Error terminology
    • When we start to create tests to have the see if the Type sanitizer works, we got an error message in the output log, but the "exitcode" was still 0, as if the TySan didn't get any error. (As it says in documentation "TypeSanitizer is still experimental. User-facing error messages should be improved in the future to remove references to LLVM IR specific terms")
    • So to migrate this (by now) we change the way we are getting the error on tests, by looking into the log and check if there is any "TypeSanitizer: type-aliasing-violation". If so, then the code has a type-aliasing-violation, while in the other Sanitizers we were just expecting the exitcode=55 (set in each env.template)
  • We also can't use the "halt_on_error", as it is yet not implemented, as the sanitizer will run until the end of the code, even if found a violation earlier.
    • TypeSanitizer - Clang
    • "The program will print an error message to stderr each time a strict aliasing violation is detected. The program won’t terminate, which will allow you to detect many strict aliasing violations in one run."
  • As LLVM TySan is really recent, we will consider that it's not compatible with other sanitizers, just to avoid some flakiness that we might encounter.

Notes for Reviewer

Pre-Review Checklist for the PR Author

  • PR title is short, expressive and meaningful
  • Commits are properly organized
  • Relevant issues are linked in the References section
  • Tests are conducted
  • Unit tests are added

Checklist for the PR Reviewer

  • Commits are properly organized and messages follow S-CORE commit guidelines
  • Unit tests have been written for new behavior
  • Public API is documented
  • PR title describes the changes

Post-review Checklist for the PR Author

  • All open points are addressed and tracked via issues

References

Closes #34

Comment thread tests/MODULE.bazel Outdated
"@score_cpp_policies//sanitizers/features:tysan",
],
llvm_version = "19.1.7",
llvm_version = "21.1.8",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In the llvm version 19.1.7, the TySan doesn't exist yet, so we bump the version here to 21.1.8.
This is a point that should be aligned with the rest of S-Core repos. It was just added here to show that the implementation is correct and the tests pass.

Comment thread README.md
| LSan + TSan | ❌ No | TSan has built-in leak detection; enabling both causes runtime conflicts |
| TySan + ASan | ❌ No | Incompatible shadow-memory runtimes |
| TySan + LSan | ❌ No | Incompatible shadow-memory runtimes |
| TySan + TSan | ❌ No | Incompatible shadow-memory runtimes |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't refer the UBSan+TySan because they work together. But as TySan is recent, and not even the exitcode or halt_on_error works correctly, we will keep it running separated from UBSan.

Comment thread tests/.bazelrc
# TySan (Clang/LLVM only — no GCC variant available).
build:feature_only_tysan --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux
build:feature_only_tysan --features=score_tysan
test:feature_only_tysan --test_env=TYSAN_OPTIONS=exitcode=55:halt_on_error=1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in the future the "halt_on_error" and "existcode" should exist, so we keep it as this by now, as it doesn't break nothing.

@armando-martins
armando-martins force-pushed the ajfm_tysan_implementation branch from 5f78102 to 2c1360a Compare September 16, 2026 09:14
@armando-martins
armando-martins marked this pull request as ready for review September 16, 2026 09:24
@armando-martins
armando-martins force-pushed the ajfm_tysan_implementation branch from 2c1360a to 46b8665 Compare September 16, 2026 13:34
@nradakovic
nradakovic self-requested a review September 16, 2026 13:40
@nradakovic
nradakovic merged commit 9bcfe82 into eclipse-score:main Sep 16, 2026
21 checks passed
@armando-martins
armando-martins deleted the ajfm_tysan_implementation branch September 17, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Add TypeSanitizer support

2 participants