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>
}
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);
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")