]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: pools: make DEBUG_MEMORY_POOLS=1 the default option
authorWilly Tarreau <w@1wt.eu>
Wed, 10 Apr 2024 07:20:19 +0000 (09:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Apr 2024 15:25:45 +0000 (17:25 +0200)
This option has been set by default for a very long time and also
complicates the manipulation of the DEBUG variable. Let's make it
the official default and permit to unset it by setting it to zero.
The other pool-related DEBUG options were adjusted to also explicitly
check for the zero value for consistency.

INSTALL
Makefile
include/haproxy/defaults.h
src/pool.c

diff --git a/INSTALL b/INSTALL
index 56e45963111eebd44ee38ccdabd4c717ebbf8fe8..07eda87df0f9a4c1a0497a1acddc6d382ddf4f77 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -691,7 +691,7 @@ these options should not be changed. Among the usable ones are:
     overflows, which may have security implications. The cost is extremely low
     (less than 1% increase in memory footprint). This is equivalent to adding
     "-dMtag" on the command line. This option is enabled in the default build
-    options.
+    options and may be disabled with -DDEBUG_MEMORY_POOLS=0.
 
   - -DDEBUG_DONT_SHARE_POOLS: this will keep separate pools for same-sized
     objects of different types. Using this increases the memory usage a little
@@ -711,12 +711,13 @@ these options should not be changed. Among the usable ones are:
     are encouraged to use it, in combination with -DDEBUG_DONT_SHARE_POOLS and
     -DDEBUG_MEMORY_POOLS, as this could catch dangerous regressions.
 
-As such, for regular production, "-DDEBUG_STRICT -DDEBUG_MEMORY_POOLS" is
-recommended. For security sensitive environments, it is recommended to use
-"-DDEBUG_STRICT -DDEBUG_STRICT_ACTION=2 -DDEBUG_MEMORY_POOLS \
--DDEBUG_DONT_SHARE_POOLS". For deployments dedicated to testing new versions or
-when trying to nail a bug down, use "-DDEBUG_STRICT=2 -DDEBUG_STRICT_ACTION=2 \
--DDEBUG_MEMORY_POOLS -DDEBUG_DONT_SHARE_POOLS -DDEBUG_POOL_INTEGRITY".
+As such, "-DDEBUG_STRICT -DDEBUG_MEMORY_POOLS" is implicit and recommended for
+production. For security sensitive environments, it is recommended to use
+"-DDEBUG_STRICT_ACTION=2 -DDEBUG_DONT_SHARE_POOLS". When testing new versions
+or trying to nail a bug down, use "-DDEBUG_STRICT=2 -DDEBUG_STRICT_ACTION=2 \
+-DDEBUG_DONT_SHARE_POOLS -DDEBUG_POOL_INTEGRITY". Finally in order to minimize
+memory usage by disabling these integrity features, it is also possible to use
+"-DDEBUG_STRICT=0 -DDEBUG_MEMORY_POOLS=0".
 
 The DEP variable is automatically set to the list of include files and also
 designates a file that contains the last build options used. It is used during
@@ -757,7 +758,7 @@ example :
 If you need to pass some defines to the preprocessor or compiler, you may pass
 them all in the DEFINE variable. Example:
 
-  $ make TARGET=generic DEFINE="-DDEBUG_DONT_SHARE_POOLS -DDEBUG_MEMORY_POOLS"
+  $ make TARGET=generic DEFINE="-DDEBUG_DONT_SHARE_POOLS"
 
 The ADDINC variable may be used to add some extra include paths; this is
 sometimes needed when cross-compiling. Similarly the ADDLIB variable may be
index 888b3d7a3da4b90a0a868f9ffefb9cc0f2d10687..441238fcd8f81708c432faff0471d637beb22e31 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -228,7 +228,7 @@ SMALL_OPTS =
 # DEBUG_NO_POOLS, DEBUG_FAIL_ALLOC, DEBUG_STRICT_ACTION=[0-3], DEBUG_HPACK,
 # DEBUG_AUTH, DEBUG_SPOE, DEBUG_UAF, DEBUG_THREAD, DEBUG_STRICT, DEBUG_DEV,
 # DEBUG_TASK, DEBUG_MEMORY_POOLS, DEBUG_POOL_TRACING, DEBUG_QPACK, DEBUG_LIST.
-DEBUG = -DDEBUG_MEMORY_POOLS
+DEBUG =
 
 #### Trace options
 # Use TRACE=1 to trace function calls to file "trace.out" or to stderr if not
index c0cb9f34b5dcfaf19611bd5f60c20d837d7352d5..336e550d83015c6483fb6b9aaef07cb2155d7689 100644 (file)
 # define DEBUG_STRICT 1
 #endif
 
+#if !defined(DEBUG_MEMORY_POOLS)
+# define DEBUG_MEMORY_POOLS 1
+#endif
+
 #endif /* _HAPROXY_DEFAULTS_H */
index 376b311e04ddd9bb401530c04fa410343835294b..ccee8c4bef1bd90d85cc69ee118bfd53a88fcc09 100644 (file)
@@ -40,31 +40,30 @@ static struct list pools __read_mostly = LIST_HEAD_INIT(pools);
 int mem_poison_byte __read_mostly = 'P';
 int pool_trim_in_progress = 0;
 uint pool_debugging __read_mostly =               /* set of POOL_DBG_* flags */
-#ifdef DEBUG_FAIL_ALLOC
+#if defined(DEBUG_FAIL_ALLOC) && (DEBUG_FAIL_ALLOC > 0)
        POOL_DBG_FAIL_ALLOC |
 #endif
-#ifdef DEBUG_DONT_SHARE_POOLS
+#if defined(DEBUG_DONT_SHARE_POOLS) && (DEBUG_DONT_SHARE_POOLS > 0)
        POOL_DBG_DONT_MERGE |
 #endif
-#ifdef DEBUG_POOL_INTEGRITY
+#if defined(DEBUG_POOL_INTEGRITY) && (DEBUG_POOL_INTEGRITY > 0)
        POOL_DBG_COLD_FIRST |
-#endif
-#ifdef DEBUG_POOL_INTEGRITY
        POOL_DBG_INTEGRITY  |
 #endif
-#ifdef CONFIG_HAP_NO_GLOBAL_POOLS
+#if defined(CONFIG_HAP_NO_GLOBAL_POOLS)
        POOL_DBG_NO_GLOBAL  |
 #endif
-#if defined(DEBUG_NO_POOLS) || defined(DEBUG_UAF)
+#if defined(DEBUG_NO_POOLS) && (DEBUG_NO_POOLS > 0)
        POOL_DBG_NO_CACHE   |
 #endif
-#if defined(DEBUG_POOL_TRACING)
+#if defined(DEBUG_POOL_TRACING) && (DEBUG_POOL_TRACING > 0)
        POOL_DBG_CALLER     |
 #endif
-#if defined(DEBUG_MEMORY_POOLS)
+#if defined(DEBUG_MEMORY_POOLS) && (DEBUG_MEMORY_POOLS > 0)
        POOL_DBG_TAG        |
 #endif
-#if defined(DEBUG_UAF)
+#if defined(DEBUG_UAF) && (DEBUG_UAF > 0)
+       POOL_DBG_NO_CACHE   |
        POOL_DBG_UAF        |
 #endif
        0;