gc_priv.h (WARN macro): Add "GC warning:" prefix.
authorHans Boehm <Hans_Boehm@hp.com>
Tue, 9 Apr 2002 00:39:16 +0000 (00:39 +0000)
committerHans Boehm <hboehm@gcc.gnu.org>
Tue, 9 Apr 2002 00:39:16 +0000 (00:39 +0000)
* include/private/gc_priv.h (WARN macro): Add "GC warning:" prefix.
(GC_large_alloc_warn_interval, GC_large_alloc_warn_suppressed):
declare.
* allchblk.c (GC_allchblk_nth): Change text and support reduced
frequency for blacklist warning message.
* misc.c (GC_large_alloc_warn_interval,
GC_large_alloc_warn_suppressed): define.
(GC_init_inner): Check GC_NO_BLACKLIST_WARNING and
GC_LARGE_ALLOC_WARN_INTERVAL environment variables.
* doc/README.environment (GC_NO_BLACKLIST_WARNING): Deprecate.
(GC_LARGE_ALLOC_WARN_INTERVAL): Add documentation.

* dyn_load.c (_DYNAMIC): Move declaration to file scope.

From-SVN: r52053

boehm-gc/ChangeLog
boehm-gc/allchblk.c
boehm-gc/doc/README.environment
boehm-gc/dyn_load.c
boehm-gc/include/private/gc_priv.h
boehm-gc/misc.c

index 4d2af97..157adaa 100644 (file)
@@ -1,3 +1,19 @@
+2002-04-08  Hans Boehm  <Hans_Boehm@hp.com>
+       
+       * include/private/gc_priv.h (WARN macro): Add "GC warning:" prefix.
+       (GC_large_alloc_warn_interval, GC_large_alloc_warn_suppressed):
+       declare.
+       * allchblk.c (GC_allchblk_nth): Change text and support reduced
+       frequency for blacklist warning message.
+       * misc.c (GC_large_alloc_warn_interval,
+       GC_large_alloc_warn_suppressed): define.
+       (GC_init_inner): Check GC_NO_BLACKLIST_WARNING and 
+       GC_LARGE_ALLOC_WARN_INTERVAL environment variables.
+       * doc/README.environment (GC_NO_BLACKLIST_WARNING): Deprecate.
+       (GC_LARGE_ALLOC_WARN_INTERVAL): Add documentation.
+
+       * dyn_load.c (_DYNAMIC): Move declaration to file scope.
+
 2002-04-04  Loren J. Rittle  <ljrittle@acm.org>
 
        * include/private/gcconfig.h: Add support for an unmapped
index 3da58c4..7d4cbd8 100644 (file)
@@ -654,9 +654,13 @@ int n;
                         && orig_avail - size_needed
                            > (signed_word)BL_LIMIT) {
                /* Punt, since anything else risks unreasonable heap growth. */
-               if (0 == GETENV("GC_NO_BLACKLIST_WARNING")) {
-                 WARN("Needed to allocate blacklisted block at 0x%lx\n",
-                      (word)hbp);
+               if (++GC_large_alloc_warn_suppressed
+                   >= GC_large_alloc_warn_interval) {
+                 WARN("Repeated allocation of very large block "
+                      "(appr. size %ld):\n"
+                      "\tMay lead to memory leak and poor performance.\n",
+                      size_needed);
+                 GC_large_alloc_warn_suppressed = 0;
                }
                size_avail = orig_avail;
              } else if (size_avail == 0 && size_needed == HBLKSIZE
index 6b25af1..c7daddb 100644 (file)
@@ -30,7 +30,16 @@ GC_NPROCS=<n> - Linux w/threads only.  Explicitly sets the number of processors
                correctness, but may lead to really horrible performance.
 
 GC_NO_BLACKLIST_WARNING - Prevents the collector from issuing
-               "Needed to allocate blacklisted block at ..." warnings.
+               warnings about allocations of very large blocks.
+               Deprecated.  Use GC_LARGE_ALLOC_WARN_INTERVAL instead.
+
+GC_LARGE_ALLOC_WARN_INTERVAL=<n> - Print every nth warning about very large
+               block allocations, starting with the nth one.  Small values
+               of n are generally benign, in that a bounded number of
+               such warnings generally indicate at most a bounded leak.
+               For best results it should be set at 1 during testing.
+               Default is 5.  Very large numbers effectively disable the
+               warning.
 
 GC_IGNORE_GCJ_INFO - Ignore the type descriptors implicitly supplied by
                     GC_gcj_malloc and friends.  This is useful for debugging
index a267637..d3ef572 100644 (file)
@@ -529,13 +529,14 @@ GC_bool GC_register_dynamic_libraries_dl_iterate_phdr()
 
 # endif
 
+#ifdef __GNUC__
+# pragma weak _DYNAMIC
+#endif
+extern ElfW(Dyn) _DYNAMIC[];
+
 static struct link_map *
 GC_FirstDLOpenedLinkMap()
 {
-#   ifdef __GNUC__
-#     pragma weak _DYNAMIC
-#   endif
-    extern ElfW(Dyn) _DYNAMIC[];
     ElfW(Dyn) *dp;
     struct r_debug *r;
     static struct link_map *cachedResult = 0;
index 642cad8..b1526aa 100644 (file)
@@ -499,7 +499,7 @@ struct hblk;        /* See below.   */
 # endif
 
 /* Print warning message, e.g. almost out of memory.   */
-# define WARN(msg,arg) (*GC_current_warn_proc)(msg, (GC_word)(arg))
+# define WARN(msg,arg) (*GC_current_warn_proc)("GC Warning: " msg, (GC_word)(arg))
 extern GC_warn_proc GC_current_warn_proc;
 
 /* Get environment entry */
@@ -1223,7 +1223,12 @@ extern word GC_root_size;        /* Total size of registered root sections */
 
 extern GC_bool GC_debugging_started;   /* GC_debug_malloc has been called. */ 
 
-                       
+extern long GC_large_alloc_warn_interval;
+       /* Interval between unsuppressed warnings.      */
+
+extern long GC_large_alloc_warn_suppressed;
+       /* Number of warnings suppressed so far.        */
+
 /* Operations */
 # ifndef abs
 #   define abs(x)  ((x) < 0? (-(x)) : (x))
index 50955f4..f607973 100644 (file)
@@ -16,6 +16,7 @@
 
 
 #include <stdio.h>
+#include <limits.h>
 #ifndef _WIN32_WCE
 #include <signal.h>
 #endif
@@ -112,6 +113,12 @@ GC_bool GC_print_back_height = 0;
   int GC_all_interior_pointers = 0;
 #endif
 
+long GC_large_alloc_warn_interval = 5;
+       /* Interval between unsuppressed warnings.      */
+
+long GC_large_alloc_warn_suppressed = 0;
+       /* Number of warnings suppressed so far.        */
+
 /*ARGSUSED*/
 GC_PTR GC_default_oom_fn GC_PROTO((size_t bytes_requested))
 {
@@ -518,11 +525,13 @@ void GC_init_inner()
     if (0 != GETENV("GC_PRINT_BACK_HEIGHT")) {
       GC_print_back_height = 1;
     }
+    if (0 != GETENV("GC_NO_BLACKLIST_WARNING")) {
+      GC_large_alloc_warn_interval = LONG_MAX;
+    }
     {
       char * time_limit_string = GETENV("GC_PAUSE_TIME_TARGET");
       if (0 != time_limit_string) {
-        long time_limit;
-        if (time_limit_string != 0) time_limit = atol(time_limit_string);
+        long time_limit = atol(time_limit_string);
         if (time_limit < 5) {
          WARN("GC_PAUSE_TIME_TARGET environment variable value too small "
               "or bad syntax: Ignoring\n", 0);
@@ -531,6 +540,18 @@ void GC_init_inner()
         }
       }
     }
+    {
+      char * interval_string = GETENV("GC_LARGE_ALLOC_WARN_INTERVAL");
+      if (0 != interval_string) {
+        long interval = atol(interval_string);
+        if (interval <= 0) {
+         WARN("GC_LARGE_ALLOC_WARN_INTERVAL environment variable has "
+              "bad value: Ignoring\n", 0);
+        } else {
+         GC_large_alloc_warn_interval = interval;
+        }
+      }
+    }
 #   ifdef UNIX_LIKE
       if (0 != GETENV("GC_LOOP_ON_ABORT")) {
         GC_set_and_save_fault_handler(looping_handler);