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

Correctly detect address sanitizer with Clang #1712

Merged
merged 1 commit into from
Feb 11, 2025
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
10 changes: 10 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@
#define VALKEY_NO_SANITIZE(sanitizer)
#endif

#if defined(__SANITIZE_ADDRESS__)
/* GCC */
#define VALKEY_ADDRESS_SANITIZER 1
#elif defined(__has_feature)
#if __has_feature(address_sanitizer)
/* Clang */
#define VALKEY_ADDRESS_SANITIZER 1
#endif
#endif

/* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use
* the plain fsync() call. */
#if (defined(__linux__) && defined(SYNC_FILE_RANGE_WAIT_BEFORE))
Expand Down
2 changes: 1 addition & 1 deletion src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -12285,7 +12285,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa
}

int dlopen_flags = RTLD_NOW | RTLD_LOCAL;
#if (defined(__linux__) || defined(__FreeBSD__)) && !defined(__SANITIZE_ADDRESS__) && defined(__GLIBC__) && __has_include(<dlfcn.h>)
#if (defined(__GLIBC__) || defined(__FreeBSD__)) && !defined(VALKEY_ADDRESS_SANITIZER) && __has_include(<dlfcn.h>)
/* RTLD_DEEPBIND, which is required for loading modules that contains the
* same symbols, does not work with ASAN. Therefore, we exclude
* RTLD_DEEPBIND when doing test builds with ASAN.
Expand Down
Loading