]> granicus.if.org Git - gc/commitdiff
2007-08-03 Hans Boehm <Hans.Boehm@hp.com>
authorhboehm <hboehm>
Sat, 4 Aug 2007 05:59:28 +0000 (05:59 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:41 +0000 (21:06 +0400)
* Makefile.direct: Remove comment fragment.
* tests/tests.am: Add smashtest.
* Makefile.in: Regenerate.
* configure.ac: Define GC_USE_DLOPEN_WRAP with redirect-malloc.
* configure: Regenerate.
* pthread_support.c: Fix comment spelling.
* include/private/gcconfig.h: Define USE_PROC_FOR_LIBRARIES with
GC_LINUX_THREADS and REDIRECT_MALLOC.
* tests/smash_test.c: Initial check-in.
* obj_map.c: Print log entry to correct file.
* include/private/thread_local_alloc.h: Add TlsAlloc error check.

ChangeLog
Makefile.direct
Makefile.in
configure
configure.ac
include/private/gcconfig.h
include/private/thread_local_alloc.h
obj_map.c
pthread_support.c
tests/smash_test.c [new file with mode: 0644]
tests/tests.am

index e36da7a66f91973487012336a182695bfb049240..3c687a7a68d04886c601983d6f3600f2a245915f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-08-03  Hans Boehm <Hans.Boehm@hp.com>
+
+       * Makefile.direct: Remove comment fragment.
+       * tests/tests.am: Add smashtest.
+       * Makefile.in: Regenerate.
+       * configure.ac: Define GC_USE_DLOPEN_WRAP with redirect-malloc.
+       * configure: Regenerate.
+       * pthread_support.c: Fix comment spelling.
+       * include/private/gcconfig.h: Define USE_PROC_FOR_LIBRARIES with
+       GC_LINUX_THREADS and REDIRECT_MALLOC.
+       * tests/smash_test.c: Initial check-in.
+       * obj_map.c: Print log entry to correct file.
+       * include/private/thread_local_alloc.h: Add TlsAlloc error check.
+
 2007-07-23  Hans Boehm <Hans.Boehm@hp.com>
 
        * alloc.c (GC_stopped_mark): Call GC_add_current_malloc_heap()
index 3d611aa78d2551bde069ccb06f101f765cfaacb3..e84959cc65c6830a20274bcb36c735fc08c16e4e 100644 (file)
@@ -214,8 +214,6 @@ HOSTCFLAGS=$(CFLAGS)
 #   the GC_debug_ functions, or through the macros that expand to these,
 #   or by redirecting malloc to GC_debug_malloc_replacement.
 #   (Also eliminates the field for the requested object size.)
-#   occasionally be useful for debugging of client code.  Slows down the
-#   collector somewhat, but not drastically.
 # -DSAVE_CALL_COUNT=<n> Set the number of call frames saved with objects
 #   allocated through the debugging interface.  Affects the amount of
 #   information generated in leak reports.  Only matters on platforms
index f4dbe12d67cca4a4eb563e3dc312b9cdcf301ace..e07d04dd176abaa6d1e4eb2ff01076445946bcc2 100644 (file)
@@ -96,7 +96,7 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = gctest$(EXEEXT) leaktest$(EXEEXT) middletest$(EXEEXT) \
-       $(am__EXEEXT_1) $(am__EXEEXT_2)
+       smashtest$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2)
 
 # C Library: Architecture Dependent
 # ---------------------------------
@@ -191,6 +191,9 @@ leaktest_DEPENDENCIES = $(am__DEPENDENCIES_2)
 am_middletest_OBJECTS = tests/middle.$(OBJEXT)
 middletest_OBJECTS = $(am_middletest_OBJECTS)
 middletest_DEPENDENCIES = $(am__DEPENDENCIES_2)
+am_smashtest_OBJECTS = tests/smash_test.$(OBJEXT)
+smashtest_OBJECTS = $(am_smashtest_OBJECTS)
+smashtest_DEPENDENCIES = $(am__DEPENDENCIES_2)
 am__test_cpp_SOURCES_DIST = tests/test_cpp.cc
 @CPLUSPLUS_TRUE@am_test_cpp_OBJECTS = tests/test_cpp.$(OBJEXT)
 test_cpp_OBJECTS = $(am_test_cpp_OBJECTS)
@@ -227,12 +230,12 @@ CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
 SOURCES = $(libcord_la_SOURCES) $(libgc_la_SOURCES) \
        $(EXTRA_libgc_la_SOURCES) $(nodist_libgc_la_SOURCES) \
        $(libgccpp_la_SOURCES) $(gctest_SOURCES) $(leaktest_SOURCES) \
-       $(middletest_SOURCES) $(test_cpp_SOURCES) \
+       $(middletest_SOURCES) $(smashtest_SOURCES) $(test_cpp_SOURCES) \
        $(threadleaktest_SOURCES)
 DIST_SOURCES = $(libcord_la_SOURCES) $(am__libgc_la_SOURCES_DIST) \
        $(EXTRA_libgc_la_SOURCES) $(am__libgccpp_la_SOURCES_DIST) \
        $(gctest_SOURCES) $(leaktest_SOURCES) $(middletest_SOURCES) \
-       $(am__test_cpp_SOURCES_DIST) \
+       $(smashtest_SOURCES) $(am__test_cpp_SOURCES_DIST) \
        $(am__threadleaktest_SOURCES_DIST)
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
        html-recursive info-recursive install-data-recursive \
@@ -491,7 +494,7 @@ dist_noinst_HEADERS = version.h include/private/gc_hdrs.h \
        include/private/thread_local_alloc.h include/cord.h \
        include/ec.h include/javaxfc.h
 TESTS = gctest$(EXEEXT) leaktest$(EXEEXT) middletest$(EXEEXT) \
-       $(am__append_6) $(am__append_8)
+       smashtest$(EXEEXT) $(am__append_6) $(am__append_8)
 pkgconfigdir = $(libdir)/pkgconfig
 dist_pkgconfig_DATA = bdw-gc.pc
 libgc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c \
@@ -555,6 +558,8 @@ leaktest_SOURCES = tests/leak_test.c
 leaktest_LDADD = $(test_ldadd)
 middletest_SOURCES = tests/middle.c
 middletest_LDADD = $(test_ldadd)
+smashtest_SOURCES = tests/smash_test.c
+smashtest_LDADD = $(test_ldadd)
 @THREADS_TRUE@threadleaktest_SOURCES = tests/thread_leak_test.c
 @THREADS_TRUE@threadleaktest_LDADD = $(test_ldadd)
 @CPLUSPLUS_TRUE@test_cpp_SOURCES = tests/test_cpp.cc
@@ -709,6 +714,11 @@ tests/middle.$(OBJEXT): tests/$(am__dirstamp) \
 middletest$(EXEEXT): $(middletest_OBJECTS) $(middletest_DEPENDENCIES) 
        @rm -f middletest$(EXEEXT)
        $(LINK) $(middletest_LDFLAGS) $(middletest_OBJECTS) $(middletest_LDADD) $(LIBS)
+tests/smash_test.$(OBJEXT): tests/$(am__dirstamp) \
+       tests/$(DEPDIR)/$(am__dirstamp)
+smashtest$(EXEEXT): $(smashtest_OBJECTS) $(smashtest_DEPENDENCIES) 
+       @rm -f smashtest$(EXEEXT)
+       $(LINK) $(smashtest_LDFLAGS) $(smashtest_OBJECTS) $(smashtest_LDADD) $(LIBS)
 tests/test_cpp.$(OBJEXT): tests/$(am__dirstamp) \
        tests/$(DEPDIR)/$(am__dirstamp)
 test_cpp$(EXEEXT): $(test_cpp_OBJECTS) $(test_cpp_DEPENDENCIES) 
@@ -732,6 +742,7 @@ mostlyclean-compile:
        -rm -f cord/cordxtra.lo
        -rm -f tests/leak_test.$(OBJEXT)
        -rm -f tests/middle.$(OBJEXT)
+       -rm -f tests/smash_test.$(OBJEXT)
        -rm -f tests/test.$(OBJEXT)
        -rm -f tests/test_cpp.$(OBJEXT)
        -rm -f tests/thread_leak_test.$(OBJEXT)
@@ -778,6 +789,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@cord/$(DEPDIR)/cordxtra.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/leak_test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/middle.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/smash_test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/test_cpp.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/thread_leak_test.Po@am__quote@
index 341638dc24340a24395d6e97a736cc5a6162af6c..bdf2da85f1c3864a7c5980be5378bec98e0a6ec2 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 1.26 .
+# From configure.ac Revision: 1.27 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for gc 7.1alpha1.
 #
@@ -21540,6 +21540,10 @@ _ACEOF
 _ACEOF
 
     fi
+    cat >>confdefs.h <<\_ACEOF
+#define GC_USE_DLOPEN_WRAP 1
+_ACEOF
+
 fi
 
 # Check whether --enable-large-config was given.
index 7ef69b53ce090e41994423ecbe045ff7f61facaa..ebe3dea7c3ef6f238ea5599d05d4a1ec7f1c6486 100644 (file)
@@ -22,7 +22,7 @@ AC_INIT(gc,7.1alpha1,Hans.Boehm@hp.com)
 AC_CONFIG_SRCDIR(gcj_mlc.c)
 AC_CANONICAL_TARGET 
 AC_PREREQ(2.53)
-AC_REVISION($Revision: 1.27 $)
+AC_REVISION($Revision: 1.28 $)
 GC_SET_VERSION
 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects nostdinc])
 AM_MAINTAINER_MODE
@@ -527,6 +527,7 @@ if test "${enable_redirect_malloc}" = yes; then
     else
        AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
     fi
+    AC_DEFINE(GC_USE_DLOPEN_WRAP)
 fi
 
 AC_ARG_ENABLE(large-config,
index 20f35bc3a1230cf8384da14bd9aa7d2ab391f575..a41da409e4e10c8d6a607a762aa0841f6e729fba 100644 (file)
     /* large.  Sometimes we're lucky and the process just dies ...     */
     /* There seems to be a similar issue with some other memory        */
     /* allocated by the dynamic loader.                                        */
-    /* This can be avoided by either:                                  */
+    /* This should be avoidable by either:                             */
     /* - Defining USE_PROC_FOR_LIBRARIES here.                         */
     /*   That performs very poorly, precisely because we end up        */
     /*   scanning cached stacks.                                       */
-    /* - Have calloc look at its callers.  That is currently what we do.*/
+    /* - Have calloc look at its callers.                              */
     /*   In spite of the fact that it is gross and disgusting.         */
-/* #   define USE_PROC_FOR_LIBRARIES */
+    /* In fact neither seems to suffice, probably in part because      */
+    /* even with USE_PROC_FOR_LIBRARIES, we don't scan parts of stack  */
+    /* segments that appear to be out of bounds.  Thus we actually     */
+    /* do both, which seems to yield the best results.                 */
+
+#   define USE_PROC_FOR_LIBRARIES
 #endif
 
 # ifndef STACK_GROWS_UP
index 4c2c5362fbcf422bdf0db0afdcc83dfe12fb35ae..90a246a0eaed384cf3e768f58a6fa5be91152bcc 100644 (file)
@@ -109,7 +109,9 @@ typedef struct thread_local_freelists {
        /* We assume 0 == success, msft does the opposite.      */
 #   define GC_key_create(key, d)  \
        ((d) != 0? (ABORT("Destructor unsupported by TlsAlloc"),0) \
-                : (*(key) = TlsAlloc(), 0))
+                : ((*(key) = TlsAlloc()) == TLS_OUT_OF_INDEXES? \
+                      (ABORT("Out of tls"), 0): \
+                      0))
 #   define GC_remove_specific(key)  /* No need for cleanup on thread exit. */
        /* Need TlsFree on process exit/detach ? */
     typedef DWORD GC_key_t;
index c295c4033b60f26828975cb83347bd668ae1900a..a17319555fe694bdad90c164d30b2da4d1070de6 100644 (file)
--- a/obj_map.c
+++ b/obj_map.c
@@ -60,7 +60,7 @@ GC_bool GC_add_map_entry(size_t granules)
     new_map = (short *)GC_scratch_alloc(MAP_LEN * sizeof(short));
     if (new_map == 0) return(FALSE);
     if (GC_print_stats)
-        GC_printf("Adding block map for size of %u granules (%u bytes)\n",
+        GC_log_printf("Adding block map for size of %u granules (%u bytes)\n",
                  (unsigned)granules, (unsigned)(GRANULES_TO_BYTES(granules)));
     if (granules == 0) {
       for (displ = 0; displ < BYTES_TO_GRANULES(HBLKSIZE); displ++) {
index 955eea2daad8b9e426cceb3c9da61aab6e472f05..df8e4b213795916de3b49a5c6a00b82fe7c06cca 100644 (file)
@@ -728,7 +728,7 @@ void GC_thr_init(void)
 #   endif /* HANDLE_FORK */
 #   if defined(INCLUDE_LINUX_THREAD_DESCR)
       /* Explicitly register the region including the address          */
-      /* of a thread local variable.  This should included thread      */
+      /* of a thread local variable.  This should include thread       */
       /* locals for the main thread, except for those allocated                */
       /* in response to dlopen calls.                                  */  
        {
diff --git a/tests/smash_test.c b/tests/smash_test.c
new file mode 100644 (file)
index 0000000..b94af90
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Test that overwrite error detection works reasonably.
+ */
+#define GC_DEBUG
+#include <gc.h>
+#include <stdio.h>
+
+#define COUNT 7000
+#define SIZE  40
+
+char * A[COUNT];
+
+int main ()
+{
+        int i;
+       char *p;
+
+       GC_INIT();
+
+        for (i = 0; i < COUNT; ++i) {
+               A[i] = p = GC_MALLOC(SIZE);
+
+               if (i%3000 == 0) GC_gcollect();
+               if (i%5678 == 0) p[SIZE + i/2000] = 42;
+       }
+       return 0;
+}
+
index aedac1fa67441ec375f41713dbd6110326a3ef29..d649d1781d58a31f9d6acd60bca26fe3384ea42c 100644 (file)
@@ -36,6 +36,11 @@ check_PROGRAMS += middletest
 middletest_SOURCES = tests/middle.c
 middletest_LDADD = $(test_ldadd)
 
+TESTS += smashtest$(EXEEXT)
+check_PROGRAMS += smashtest
+smashtest_SOURCES = tests/smash_test.c
+smashtest_LDADD = $(test_ldadd)
+
 #TESTS += tracetest$(EXEEXT)
 #check_PROGRAMS += tracetest
 #tracetest_SOURCES = tests/trace_test.c