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

[FEATURE] add AddressSanitizer as an option #41

Closed
yunwei37 opened this issue Jul 30, 2022 · 1 comment · Fixed by #42
Closed

[FEATURE] add AddressSanitizer as an option #41

yunwei37 opened this issue Jul 30, 2022 · 1 comment · Fixed by #42
Assignees
Labels
acknowledged The issue is being worked on enhancement New feature or request

Comments

@yunwei37
Copy link
Contributor

Is your feature request related to a problem? Please describe.

AddressSanitizer is a fast memory error detector. It consists of a compiler instrumentation module and a run-time library. see https://github.com/google/sanitizers/wiki/AddressSanitizer. The tool can detect the following types of bugs:

  • Out-of-bounds accesses to heap, stack and globals
  • Use-after-free
  • Use-after-return (clang flag -fsanitize-address-use-after-return=(never|runtime|always) default: runtime)
  • Enable with: ASAN_OPTIONS=detect_stack_use_after_return=1 (already enabled on Linux).
  • Disable with: ASAN_OPTIONS=detect_stack_use_after_return=0.
  • Use-after-scope (clang flag -fsanitize-address-use-after-scope)
  • Double-free, invalid free
  • Memory leaks (experimental)

This tool is very fast. The average slowdown of the instrumented program is ~2x (see

And I think it's quite useful in C/C++ projects. You can simply enable it by compiling and linking your program with -fsanitize=address flag.

Describe the solution you'd like

Maybe we can add it as an option in cmake/StandardSettings.cmake ?

For example, like this:

option(${PROJECT_NAME}_ENABLE_ASAN "Enable Address Sanitize to detect memory error." ON)
if(${PROJECT_NAME}_ENABLE_ASAN)
  add_compile_options(-fsanitize=address)
  add_link_options(-fsanitize=address)
endif()
@yunwei37 yunwei37 added the enhancement New feature or request label Jul 30, 2022
@filipdutescu filipdutescu self-assigned this Dec 16, 2022
@filipdutescu filipdutescu added the acknowledged The issue is being worked on label Dec 16, 2022
@filipdutescu
Copy link
Owner

filipdutescu commented Dec 16, 2022

That sounds great! Thanks for submitting the PR and hope we merge it ASAP 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledged The issue is being worked on enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants