Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime Sanitizer #1062

Open
mhasel opened this issue Jan 2, 2024 · 1 comment
Open

Runtime Sanitizer #1062

mhasel opened this issue Jan 2, 2024 · 1 comment
Labels

Comments

@mhasel
Copy link
Member

mhasel commented Jan 2, 2024

Is your feature request related to a problem? Please describe.
Some of the compile-time validations we have in place (e.g. implicit downcasts #828) produce a lot of false positives due to internal type-promotions and would be a lot better suited to be validated at runtime.

Describe the solution you'd like
Clang provides an --fsanitize compile flag which modifies the generated code to add runtime validations for many hard-to-catch errors and undefined behaviour (UndefinedBehaviourSanitizer)
Some checks also provide a small (sometimes optional) runtime library which is automatically linked when the flag is passed to improve error-reporting.

I think this would be a great feature to add and would allow us to provide additional, optional validation-options or improve upon existing validations that are currently in a "half-baked" state.

@mhasel mhasel added enhancement New feature or request codegen labels Jan 2, 2024
@mhasel mhasel changed the title Sanitizer options Runtime Sanitizer Jan 2, 2024
@corbanvilla
Copy link
Contributor

@mhasel address sanitizing is pretty straightforward to add, as it's pretty much self-contained in an LLVM pass. I added it to IR in #1089

As I understand it, Memory Sanitizer doesn't necessarily make sense for structured text... I can't think of any times you would be accessing uninitialized variables, for example. Address sanitizer will catch out of bounds accesses as well.

Unfortunately UndefinedBehaviourSanitizer (UBSAN) is implemented through the clang frontend, so adding support seems non-trivial. May be still worth looking into, or building a new solution that runs as an LLVM pass for more simple cases like integer overflows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants