From dbc74c0b536974ecdd13e821cb6a15006649e4fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 13 Nov 2016 07:35:51 +0000 Subject: [PATCH] Several memory sanitizer --- deps/Makefile | 1 + lib/MySQL_Thread.cpp | 4 ++++ lib/ProxySQL_Admin.cpp | 5 ++++- src/main.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/deps/Makefile b/deps/Makefile index 6a89349be..6f380f489 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -71,6 +71,7 @@ re2/re2/obj/libre2.a: cd re2 && tar -zxf re2.tar.gz # cd re2/re2 && sed -i -e 's/-O3 -g /-O3 -fPIC /' Makefile # cd re2 && patch re2/util/mutex.h < mutex.h.patch + cd re2/re2 && sed -i -e 's/-O3 /-O3 -DMEMORY_SANITIZER /' Makefile cd re2/re2 && CC=${CC} CXX=${CXX} ${MAKE} re2: re2/re2/obj/libre2.a diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 69580d98e..64bc4aa6b 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -2515,7 +2515,9 @@ __run_skip_2: } } else { //spin_wrlock(&GloMTH->rwlock_resumes); + VALGRIND_DISABLE_ERROR_REPORTING; pthread_mutex_lock(&thr->myexchange.mutex_resumes); + VALGRIND_ENABLE_ERROR_REPORTING; if (shutdown==0 && thr->shutdown==0 && thr->myexchange.resume_mysql_sessions->len) { //unsigned int w=rand()%(GloMTH->num_threads); //w++; @@ -2527,7 +2529,9 @@ __run_skip_2: } } //spin_wrunlock(&GloMTH->rwlock_resumes); + VALGRIND_DISABLE_ERROR_REPORTING; pthread_mutex_unlock(&thr->myexchange.mutex_resumes); + VALGRIND_ENABLE_ERROR_REPORTING; } } else { // iterate through all sessions and process the session logic diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 9b8c935ff..820eff25a 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -2423,7 +2423,10 @@ __end_while_pool: char *add=NULL; char *port=NULL; close(fds[i].fd); c_split_2(socket_names[i], ":" , &add, &port); - if (atoi(port)==0) { unlink(socket_names[i]); } + if (atoi(port)==0) { + if (socket_names[i]) + unlink(socket_names[i]); + } } free(arg); return NULL; diff --git a/src/main.cpp b/src/main.cpp index bf0d7a692..a7da9e7c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -128,11 +128,11 @@ using namespace std; static volatile int load_; //__thread l_sfp *__thr_sfp=NULL; -#ifdef DEBUG -const char *malloc_conf = "xmalloc:true,lg_tcache_max:16,purge:decay,junk:true,tcache:false"; -#else +//#ifdef DEBUG +//const char *malloc_conf = "xmalloc:true,lg_tcache_max:16,purge:decay,junk:true,tcache:false"; +//#else const char *malloc_conf = "xmalloc:true,lg_tcache_max:16,purge:decay"; -#endif /* DEBUG */ +//#endif /* DEBUG */ //const char *malloc_conf = "prof_leak:true,lg_prof_sample:0,prof_final:true,xmalloc:true,lg_tcache_max:16"; int listen_fd;