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

By pass address sanitizer for BadEuler1DSolver member function #261

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ if(USE_SANITIZER)
message(STATUS "use sanitizer")
set(SANITIZER_LIST "undefined,leak,address")
add_compile_options(-fsanitize=${SANITIZER_LIST})
add_compile_options(-DUSE_SANITIZER)
add_link_options(-fsanitize=${SANITIZER_LIST})
else()
message(STATUS "not use sanitizer")
Expand Down
7 changes: 7 additions & 0 deletions cpp/modmesh/modmesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,11 @@
#include <modmesh/mesh/mesh.hpp>
#include <modmesh/toggle/toggle.hpp>

// TODO Add MSVC case once sanitizer can be default turned on for CI testing
#if defined(USE_SANITIZER) && (defined(__clang__) || defined(__GNUC__))
#define ASAN_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
#else
#define ASAN_NO_SANITIZE_ADDRESS
#endif

// vim: set ff=unix fenc=utf8 et sw=4 ts=4 sts=4:
6 changes: 4 additions & 2 deletions cpp/modmesh/spacetime/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ class ElementBase

value_type x() const { return *m_xptr; }
value_type dx() const { return xpos() - xneg(); }
value_type xneg() const { return *(m_xptr - 1); }
value_type xpos() const { return *(m_xptr + 1); }

// By pass address sanitizer check, more information please reference to issue #257
ASAN_NO_SANITIZE_ADDRESS value_type xneg() const { return *(m_xptr - 1); }
ASAN_NO_SANITIZE_ADDRESS value_type xpos() const { return *(m_xptr + 1); }
value_type xctr() const { return static_cast<ET const *>(this)->xctr(); }

void move(ssize_t offset) { m_xptr += offset; }
Expand Down