From: Francesco Chemolli Date: Mon, 8 Jun 2020 21:40:57 +0000 (+0000) Subject: Remove leakfinder (--enable-leakfinder) (#655) X-Git-Tag: 4.15-20210522-snapshot~101 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d13b66167d8864485f5448fbc4ae7c7e02619e2a;p=thirdparty%2Fsquid.git Remove leakfinder (--enable-leakfinder) (#655) There are better leak finding tools for most use cases now. The removed code can be manually added back for experiments in other use cases. The original leakfinder design required code modifications anyway. --- diff --git a/configure.ac b/configure.ac index cbd9c4f5af..e4ec9ab7c3 100644 --- a/configure.ac +++ b/configure.ac @@ -2386,21 +2386,6 @@ else fi fi -dnl Enable Leak Finding Functions -AC_ARG_ENABLE(leakfinder, - AS_HELP_STRING([--enable-leakfinder], - [Enable Leak Finding code. Enabling this alone does nothing; - you also have to modify the source code to use the leak - finding functions. Probably Useful for hackers only.]), [ - SQUID_YESNO([$enableval], - [unrecognized argument to --enable-leakfinder: $enableval]) -]) -AC_MSG_NOTICE([Leak Finder enabled: ${enable_leakfinder:=no}]) -SQUID_DEFINE_BOOL(USE_LEAKFINDER,$enable_leakfinder, - [Enable code for assisting in finding memory leaks. Not for the faint of heart]) -AM_CONDITIONAL(ENABLE_LEAKFINDER, [test "x$enable_leakfinder" = "xyes"]) - - AC_ARG_ENABLE(follow-x-forwarded-for, AS_HELP_STRING([--enable-follow-x-forwarded-for], [Enable support for following the X-Forwarded-For diff --git a/include/leakcheck.h b/include/leakcheck.h deleted file mode 100644 index f3974c12b8..0000000000 --- a/include/leakcheck.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 1996-2020 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef _SQUID_LEAKCHECK_H -#define _SQUID_LEAKCHECK_H - -#if LEAK_CHECK_MODE && 0 /* doesn't work at the moment */ -#define LOCAL_ARRAY(type,name,size) \ - static type *local_##name=NULL; \ - type *name = local_##name ? local_##name : \ - ( local_##name = (type *)xcalloc(size, sizeof(type)) ) -#else -#define LOCAL_ARRAY(type,name,size) static type name[size] -#endif - -#endif - diff --git a/include/squid.h b/include/squid.h index 953bbd08c1..0dc02cc21f 100644 --- a/include/squid.h +++ b/include/squid.h @@ -72,8 +72,7 @@ using namespace Squid; /** \endcond */ #endif -// temporary for the definition of LOCAL_ARRAY -#include "leakcheck.h" +#define LOCAL_ARRAY(type, name, size) static type name[size] #endif /* SQUID_CONFIG_H */ diff --git a/squid.dox b/squid.dox index 355b8dda66..e8710e8a3a 100644 --- a/squid.dox +++ b/squid.dox @@ -2092,7 +2092,6 @@ PREDEFINED = __cplusplus \ USE_IDENT \ USE_IPV6 \ USE_KQUEUE \ - USE_LEAKFINDER \ USE_LIBCAP \ USE_LOADABLE_MODULES \ USE_MIT_KRB5 \ diff --git a/src/LeakFinder.cc b/src/LeakFinder.cc deleted file mode 100644 index 92a30729d1..0000000000 --- a/src/LeakFinder.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 1996-2020 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -/* DEBUG: section 45 Callback Data Registry */ - -/* - * Use these to find memory leaks - */ - -#include "squid.h" - -#if USE_LEAKFINDER - -#include "LeakFinder.h" -#include "SquidTime.h" -#include "Store.h" - -/* ========================================================================= */ - -LeakFinderPtr::LeakFinderPtr(void *p, const char *f, const int l) : - file(f), - line(l), - when(squid_curtime) -{ - // XXX: these bits should be done by hash_link() - key = p; - next = NULL; -} - -/* ========================================================================= */ - -LeakFinder::LeakFinder() : - count(0), - last_dump(0) -{ - debugs(45, 3, "LeakFinder constructed"); - table = hash_create(cmp, 1 << 8, hash); -#if 0 - /* if this is desired to reinstate, add a - * RegisterWithCacheManager method - */ - cachemgrRegister("leaks", - "Memory Leak Tracking", - cachemgr_dump, 0, 1); -#endif -} - -void * -LeakFinder::addSome(void *p, const char *file, int line) -{ - assert(hash_lookup(table, p) == NULL); - LeakFinderPtr *c = new LeakFinderPtr(p, file, line); - hash_join(table, c); - ++count; - return p; -} - -void * -LeakFinder::touch(void *p, const char *file, int line) -{ - assert(p); - LeakFinderPtr *c = (LeakFinderPtr *) hash_lookup(table, p); - assert(c); - c->file = file; - c->line = line; - c->when = squid_curtime; - return p; -} - -void * -LeakFinder::freeSome(void *p, const char *file, int line) -{ - assert(p); - LeakFinderPtr *c = (LeakFinderPtr *) hash_lookup(table, p); - assert(c); - hash_remove_link(table, c); - --count; - delete c; - dump(); - return p; -} - -/* ========================================================================= */ - -int -LeakFinder::cmp(const void *p1, const void *p2) -{ - return (char *) p1 - (char *) p2; -} - -unsigned int -LeakFinder::hash(const void *p, unsigned int mod) -{ - return ((unsigned long) p >> 8) % mod; -} - -void -LeakFinder::dump() -{ - if (0 == count) - return; - - if (squid_curtime == last_dump) - return; - - last_dump = squid_curtime; - - debugs(45, DBG_IMPORTANT, "Tracking " << count << " pointers"); - - hash_first(table); - - LeakFinderPtr *c; - - while ((c = (LeakFinderPtr *)hash_next(table))) { - debugs(45, DBG_IMPORTANT, std::setw(20) << c->key << " last used " << std::setw(9) << (squid_curtime - c->when) << - " seconds ago by " << c->file << ":" << c->line); - } -} - -#endif /* USE_LEAKFINDER */ - diff --git a/src/LeakFinder.h b/src/LeakFinder.h deleted file mode 100644 index b9b0b3324f..0000000000 --- a/src/LeakFinder.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 1996-2020 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_LEAKFINDER_H -#define SQUID_LEAKFINDER_H - -#if USE_LEAKFINDER - -#include "hash.h" - -#define leakAdd(p,l) if (l) l->addSome(p,__FILE__,__LINE__) -#define leakTouch(p,l) if (l) l->touch(p,__FILE__,__LINE__) -#define leakFree(p,l) if (l) l->freeSome(p,__FILE__,__LINE__) - -class LeakFinderPtr : public hash_link -{ - -public: - LeakFinderPtr(void *, const char *, const int); - const char *file; - int line; - time_t when; -}; - -class LeakFinder -{ - -public: - LeakFinder(); - ~LeakFinder(); - - void *addSome(void *, const char *, const int); - - void *touch(void *, const char *, const int); - - void *freeSome(void *, const char *, const int); - - void dump(); - -private: - static HASHCMP cmp; - - static HASHHASH hash; - - hash_table *table; - - int count; - - time_t last_dump; - -}; - -#else /* USE_LEAKFINDER */ - -class LeakFinder {}; - -#define leakAdd(p,l) (void)0 -#define leakTouch(p,l) (void)0 -#define leakFree(p,l) (void)0 -#endif /* USE_LEAKFINDER */ - -#endif /* SQUID_LEAKFINDER_H */ - diff --git a/src/Makefile.am b/src/Makefile.am index c3ed4d642d..a547eab1e0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -134,12 +134,6 @@ if ENABLE_HTCP HTCPSOURCE = htcp.cc htcp.h endif -if ENABLE_LEAKFINDER -LEAKFINDERSOURCE = LeakFinder.cc -else -LEAKFINDERSOURCE = -endif - if ENABLE_UNLINKD UNLINKDSOURCE = unlinkd.h unlinkd.cc UNLINKD = unlinkd @@ -364,7 +358,6 @@ squid_SOURCES = \ $(IPC_SOURCE) \ ipcache.cc \ ipcache.h \ - $(LEAKFINDERSOURCE) \ LogTags.cc \ LogTags.h \ lookup_t.h \ @@ -505,8 +498,6 @@ EXTRA_squid_SOURCES = \ ipc.cc \ ipc_win32.cc \ ProfStats.cc \ - LeakFinder.cc \ - LeakFinder.h \ $(SNMP_ALL_SOURCE) \ $(UNLINKDSOURCE) \ $(WIN32_ALL_SOURCE) \ diff --git a/src/icmp/Icmp4.cc b/src/icmp/Icmp4.cc index 9500215b56..ec321a2b08 100644 --- a/src/icmp/Icmp4.cc +++ b/src/icmp/Icmp4.cc @@ -17,7 +17,6 @@ #include "Debug.h" #include "Icmp4.h" #include "IcmpPinger.h" -#include "leakcheck.h" #include "SquidTime.h" static const char * diff --git a/src/icmp/Icmp6.cc b/src/icmp/Icmp6.cc index e9160a2cc6..c7bc8bb45f 100644 --- a/src/icmp/Icmp6.cc +++ b/src/icmp/Icmp6.cc @@ -17,7 +17,6 @@ #include "Debug.h" #include "Icmp6.h" #include "IcmpPinger.h" -#include "leakcheck.h" #include "SquidTime.h" // Some system headers are only neeed internally here. diff --git a/test-suite/buildtests/layer-01-minimal.opts b/test-suite/buildtests/layer-01-minimal.opts index aa6430ce50..5ee2364ce8 100644 --- a/test-suite/buildtests/layer-01-minimal.opts +++ b/test-suite/buildtests/layer-01-minimal.opts @@ -73,7 +73,6 @@ DISTCHECK_CONFIGURE_FLAGS=" \ --disable-pf-transparent \ --disable-linux-netfilter \ --disable-linux-tproxy \ - --disable-leakfinder \ --disable-follow-x-forwarded-for \ --disable-ident-lookups \ --disable-default-hostsfile \ diff --git a/test-suite/buildtests/layer-02-maximus.opts b/test-suite/buildtests/layer-02-maximus.opts index a45d680d4c..cbbef31b7d 100644 --- a/test-suite/buildtests/layer-02-maximus.opts +++ b/test-suite/buildtests/layer-02-maximus.opts @@ -79,7 +79,6 @@ DISTCHECK_CONFIGURE_FLAGS=" \ --enable-select \ --enable-http-violations \ --enable-ipfw-transparent \ - --enable-leakfinder \ --enable-follow-x-forwarded-for \ --enable-ident-lookups \ --enable-default-hostsfile=/etc/hosts \ diff --git a/test-suite/buildtests/layer-04-noauth-everything.opts b/test-suite/buildtests/layer-04-noauth-everything.opts index 737932bd88..a61a597892 100644 --- a/test-suite/buildtests/layer-04-noauth-everything.opts +++ b/test-suite/buildtests/layer-04-noauth-everything.opts @@ -80,7 +80,6 @@ DISTCHECK_CONFIGURE_FLAGS=" \ --enable-select \ --enable-http-violations \ --enable-ipfw-transparent \ - --enable-leakfinder \ --enable-follow-x-forwarded-for \ --enable-ident-lookups \ --enable-internal-dns \