[education/rkward] rkward/rbackend: Disable dlmopen when using address sanitzer
Thomas Friedrichsmeier
null at kde.org
Sat May 11 14:00:56 BST 2024
Git commit 22292888de93a5d35d1fb680b99c556c234128b3 by Thomas Friedrichsmeier.
Committed on 11/05/2024 at 12:56.
Pushed by tfry into branch 'master'.
Disable dlmopen when using address sanitzer
M +13 -4 rkward/rbackend/rkrbackend_dlopen.cpp
https://invent.kde.org/education/rkward/-/commit/22292888de93a5d35d1fb680b99c556c234128b3
diff --git a/rkward/rbackend/rkrbackend_dlopen.cpp b/rkward/rbackend/rkrbackend_dlopen.cpp
index 00bb46add..c14eb9295 100644
--- a/rkward/rbackend/rkrbackend_dlopen.cpp
+++ b/rkward/rbackend/rkrbackend_dlopen.cpp
@@ -29,13 +29,22 @@ void *resolve_symb(void* dllinfo, const char* name) {
#endif
}
+// See https://stackoverflow.com/questions/34813412/how-to-detect-if-building-with-address-sanitizer-when-building-with-gcc-4-8
+#if defined(__has_feature)
+# if __has_feature(address_sanitizer) // for clang
+# define __SANITIZE_ADDRESS__
+# endif
+#endif
+
auto loadlib(const char* name) {
-#ifdef Win32
+#if defined(Win32)
auto ret = LoadLibraryA(name);
-#elif defined(LM_ID_NEWLM)
- auto ret = dlmopen(LM_ID_NEWLM, name, RTLD_NOW | RTLD_LOCAL); // NOTE: RTLD_DEEPBIND causes undiagnosed runtime failure on Suse Tumbleweed around 05/24 (while it works, elsewhere)
+#elif defined(LM_ID_NEWLM) && !defined(__SANITIZE_ADDRESS__)
+ auto ret = dlmopen(LM_ID_NEWLM, name, RTLD_NOW | RTLD_LOCAL);
#else
- auto ret = dlopen(name, RTLD_NOW | RTLD_LOCAL);
+ auto ret = dlopen(name, RTLD_NOW | RTLD_LOCAL); // NOTE: RTLD_DEEPBIND causes undiagnosed runtime failure on Suse Tumbleweed around 05/24 (while it works, elsewhere)
+ // possibly again due to address sanitization on the gitlab job?
+#warning dlmopen is not available on this platform, or disabled due to compiling with address_sanitizer
#endif
if (!ret) {
#ifdef Win32
More information about the rkward-tracker
mailing list