From 26e5f9dda13efad33e867742ea4e42e479b51b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 16 Jan 2018 22:57:52 +0200 Subject: MDEV-14229: Stack trace is not resolved for shared objects Resolving a stacktrace including functions in dynamic libraries requires us to look inside the libraries for the symbols. Addr2line needs to be started with the correct binary for each address on the stack. To do this, figure out which library it is using dladdr, then if the addr2line binary was started with a different binary, fork it again with the correct one. We only have one addr2line process running at any point during the stacktrace resolving step. The maximum number of forks for addr2line should generally be around 6. One for server stacktrace code, one for plugin code, one when going back into server code, one for pthread library, one for libc, one for the _start function in the server. More can come up if plugin calls server function which goes back to a plugin, etc. --- include/my_global.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/my_global.h') diff --git a/include/my_global.h b/include/my_global.h index cf140cf54ce..767ac3e459e 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1373,11 +1373,15 @@ static inline char *dlerror(void) #ifndef HAVE_DLERROR #define dlerror() "" #endif +#ifndef HAVE_DLADDR +#define dladdr(A, B) 0 +#endif #else #define dlerror() "No support for dynamic loading (static build?)" #define dlopen(A,B) 0 #define dlsym(A,B) 0 #define dlclose(A) 0 +#define dladdr(A, B) 0 #endif /* -- cgit v1.2.1 From 6c60c809bb90e229f6f6c09ea2dbb9c87e2759ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Fri, 19 Jan 2018 18:04:51 +0200 Subject: Add dummy defintion for Dl_info in case we're missing dladdr --- include/my_global.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/my_global.h') diff --git a/include/my_global.h b/include/my_global.h index 767ac3e459e..ab7e485a1a0 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1375,6 +1375,8 @@ static inline char *dlerror(void) #endif #ifndef HAVE_DLADDR #define dladdr(A, B) 0 +/* Dummy definition in case we're missing dladdr() */ +typedef int Dl_info; #endif #else #define dlerror() "No support for dynamic loading (static build?)" @@ -1382,6 +1384,8 @@ static inline char *dlerror(void) #define dlsym(A,B) 0 #define dlclose(A) 0 #define dladdr(A, B) 0 +/* Dummy definition in case we're missing dladdr() */ +typedef int Dl_info; #endif /* -- cgit v1.2.1 From 204cb85aab3e6326e9f7a51c478efd6fad44801a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 20 Jan 2018 11:45:23 +0100 Subject: Fix compilation without dlopen --- include/my_global.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/my_global.h') diff --git a/include/my_global.h b/include/my_global.h index ab7e485a1a0..194e1039c60 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1376,7 +1376,7 @@ static inline char *dlerror(void) #ifndef HAVE_DLADDR #define dladdr(A, B) 0 /* Dummy definition in case we're missing dladdr() */ -typedef int Dl_info; +typedef struct { const char *dli_fname, dli_fbase; } Dl_info; #endif #else #define dlerror() "No support for dynamic loading (static build?)" @@ -1385,7 +1385,7 @@ typedef int Dl_info; #define dlclose(A) 0 #define dladdr(A, B) 0 /* Dummy definition in case we're missing dladdr() */ -typedef int Dl_info; +typedef struct { const char *dli_fname, dli_fbase; } Dl_info; #endif /* -- cgit v1.2.1