New sanitizer option to disable dlclose processing 90/216690/2 accepted/tizen_base accepted/tizen/base/20191105.214104 submit/tizen_base/20191101.071449
authorMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Mon, 17 Jun 2019 17:27:16 +0000 (20:27 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Fri, 1 Nov 2019 06:25:14 +0000 (06:25 +0000)
This is a simple workaround for https://github.com/google/sanitizers/issues/89:
Avoid <unknown module> frames for functions from unloaded shared library.

Rtld will unload dynamically loaded shared objects, we are not preventing
unloading in this, just deferring it.

This could hide potential bugs like accesing library range addressing after
dlclose or some tricky cases for functions with __attribute__((__destructor__))
+ code that relies on explicit call to dlclose.

Change-Id: I14fb2b8846350e07040d6f9215b936d9b2956faa
Signed-off-by: Mikhail Kashkarov <m.kashkarov@partner.samsung.com>
libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
libsanitizer/sanitizer_common/sanitizer_flags.inc

index e8cee58..f652db3 100644 (file)
@@ -6016,6 +6016,10 @@ INTERCEPTOR(void*, dlopen, const char *filename, int flag) {
 }
 
 INTERCEPTOR(int, dlclose, void *handle) {
+  // Do not call dlclose to keep mapped memory ranges information to avoid
+  // <unknown module> frames.
+  if (common_flags()->no_dlclose)
+    return 0;
   void *ctx;
   MAYBE_FORWARD_TO_REAL(dlclose, handle);
   COMMON_INTERCEPTOR_ENTER_NOIGNORE(ctx, dlclose, handle);
index a80c993..a1086a7 100644 (file)
@@ -245,6 +245,9 @@ COMMON_FLAG(bool, intercept_stat, true,
 COMMON_FLAG(bool, intercept_send, true,
             "If set, uses custom wrappers for send* functions "
             "to find more errors.")
+COMMON_FLAG(bool, no_dlclose, false,
+           "If set, dlclose will not be executed to avoid <unknown module> "
+           "frames.")
 COMMON_FLAG(bool, decorate_proc_maps, false, "If set, decorate sanitizer "
                                              "mappings in /proc/self/maps with "
                                              "user-readable names")