2007-01-02 Hans Boehm <Hans.Boehm@hp.com>
authorhboehm <hboehm>
Thu, 3 Jan 2008 01:21:05 +0000 (01:21 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:42 +0000 (21:06 +0400)
* alloc.c (GC_add_to_heap): Call GC_install_header(p) AFTER
adjusting p.

ChangeLog
alloc.c

index 0df263f..1623bb5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-02  Hans Boehm <Hans.Boehm@hp.com>
+
+       * alloc.c (GC_add_to_heap): Call GC_install_header(p) AFTER
+       adjusting p.
+
 2007-12-23  Hans Boehm <Hans.Boehm@hp.com>
 
        * Makefile.am: Add NT_X64_THREADS_MAKEFILE.
diff --git a/alloc.c b/alloc.c
index 426ab5a..f996bff 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -797,13 +797,6 @@ void GC_add_to_heap(struct hblk *p, size_t bytes)
     if (GC_n_heap_sects >= MAX_HEAP_SECTS) {
        ABORT("Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS");
     }
-    phdr = GC_install_header(p);
-    if (0 == phdr) {
-       /* This is extremely unlikely. Can't add it.  This will         */
-       /* almost certainly result in a 0 return from the allocator,    */
-       /* which is entirely appropriate.                               */
-       return;
-    }
     while ((word)p <= HBLKSIZE) {
         /* Can't handle memory near address zero. */
         ++p;
@@ -817,6 +810,13 @@ void GC_add_to_heap(struct hblk *p, size_t bytes)
         if (0 == bytes) return;
        endp -= HBLKSIZE;
     }
+    phdr = GC_install_header(p);
+    if (0 == phdr) {
+       /* This is extremely unlikely. Can't add it.  This will         */
+       /* almost certainly result in a 0 return from the allocator,    */
+       /* which is entirely appropriate.                               */
+       return;
+    }
     GC_ASSERT(endp > (word)p && endp == (word)p + bytes);
     GC_heap_sects[GC_n_heap_sects].hs_start = (ptr_t)p;
     GC_heap_sects[GC_n_heap_sects].hs_bytes = bytes;