Fix 'GC_written_pages never read' code defect (GWW_VDB)
authorIvan Maidanski <ivmai@mail.ru>
Tue, 6 Dec 2016 07:49:52 +0000 (10:49 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 6 Dec 2016 07:49:52 +0000 (10:49 +0300)
* include/private/gc_priv.h [GWW_VDB] (GC_written_pages,
GC_arrays._written_pages): Do not define unless CHECKSUMS.
* os_dep.c [GWW_VDB] (GC_or_pages): Likewise.
* os_dep.c [GWW_VDB] (GC_gww_read_dirty): Call
GC_or_pages(GC_written_pages) only if CHECKSUMS.

include/private/gc_priv.h
os_dep.c

index e5c870d..218ca72 100644 (file)
@@ -1316,7 +1316,7 @@ struct _GC_arrays {
     volatile page_hash_table _dirty_pages;
                         /* Pages dirtied since last GC_read_dirty. */
 # endif
-# if defined(PROC_VDB) || defined(GWW_VDB)
+# if (defined(CHECKSUMS) && defined(GWW_VDB)) || defined(PROC_VDB)
 #   define GC_written_pages GC_arrays._written_pages
     page_hash_table _written_pages;     /* Pages ever dirtied   */
 # endif
index b78943a..3a65074 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -2714,13 +2714,6 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
 #endif
 
 #if defined(PROC_VDB) || defined(GWW_VDB)
-  /* Add all pages in pht2 to pht1 */
-  STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
-  {
-    register unsigned i;
-    for (i = 0; i < PHT_SIZE; i++) pht1[i] |= pht2[i];
-  }
-
 # ifdef MPROTECT_VDB
     STATIC GC_bool GC_gww_page_was_dirty(struct hblk * h)
 # else
@@ -2735,6 +2728,13 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
   }
 
 # if defined(CHECKSUMS) || defined(PROC_VDB)
+    /* Add all pages in pht2 to pht1.   */
+    STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
+    {
+      register unsigned i;
+      for (i = 0; i < PHT_SIZE; i++) pht1[i] |= pht2[i];
+    }
+
     /* Used only if GWW_VDB. */
 #   ifdef MPROTECT_VDB
       STATIC GC_bool GC_gww_page_was_ever_dirty(struct hblk * h)
@@ -2852,7 +2852,9 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
       /* up.  But that should still be handled correctly.                */
     }
 
-    GC_or_pages(GC_written_pages, GC_grungy_pages);
+#   ifdef CHECKSUMS
+      GC_or_pages(GC_written_pages, GC_grungy_pages);
+#   endif
   }
 #endif /* GWW_VDB */