-
Notifications
You must be signed in to change notification settings - Fork 109
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
Add ASAN #1394
base: main
Are you sure you want to change the base?
Add ASAN #1394
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,7 @@ target_compile_features(libAtomVM PUBLIC c_std_11) | |
if (CMAKE_C_COMPILER_ID STREQUAL "GNU") | ||
target_compile_options(libAtomVM PUBLIC -Wall ${MAYBE_PEDANTIC_FLAG} ${MAYBE_WERROR_FLAG} -Wextra -ggdb -Werror=incompatible-pointer-types) | ||
elseif (CMAKE_C_COMPILER_ID MATCHES "Clang") | ||
target_compile_options(libAtomVM PUBLIC -Wall --extra-warnings -Werror=incompatible-pointer-types ${MAYBE_WERROR_FLAG}) | ||
target_compile_options(libAtomVM PUBLIC -Wall --extra-warnings -Werror=incompatible-pointer-types -g ${MAYBE_WERROR_FLAG}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is build mode dictated by DEBUG env variable? I couldn't find reference to debug/release in the code. |
||
endif() | ||
|
||
if (ENABLE_REALLOC_GC) | ||
|
@@ -132,6 +132,11 @@ if (ADVANCED_TRACING) | |
target_compile_definitions(libAtomVM PUBLIC ENABLE_ADVANCED_TRACE) | ||
endif() | ||
|
||
if(ENABLE_ASAN) | ||
target_compile_options(libAtomVM PUBLIC -fsanitize=address -fno-omit-frame-pointer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. Logically, omitting frame pointer is an optimization so every platform should support that (making one less available register if disabled) but from reading GCC docs it's noop on archs that don't benefit from it. https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Optimize-Options.html |
||
target_link_options(libAtomVM PUBLIC -fsanitize=address) | ||
endif() | ||
|
||
target_link_libraries(libAtomVM PUBLIC m) | ||
include(CheckCSourceCompiles) | ||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unknown-pragmas") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this should be the default: it is very useful during development, but it should be off during release.
Also I'm not sure how interacts with platforms that do not properly support
-fsanitize=address
such as ESP32.So maybe it should be manually enabled (and we might suggest it in our documentation) and of course we should add a job in our CI that enables it. After all what really matter is not merging code that fails those checks.
I think we should have jobs and options for undefined behavior sanitizer, thread sanitizer and memory sanitizer and they should be part of our CI as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I don't have means to test embedded platforms so most of my testing comes from unix and WASM port.
What do you think about adding
and corresponding ifs in libAtomVM CMakeList?
Is there any way to create local CMakeLists or you need to use env variables when running CMake to set those options?