From 8d43b72f2a690c77bdb376c461ee1c6360710745 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 6 Dec 2016 10:49:52 +0300 Subject: [PATCH] Fix 'GC_written_pages never read' code defect (GWW_VDB) * 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 | 2 +- os_dep.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index e5c870d..218ca72 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -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 diff --git a/os_dep.c b/os_dep.c index b78943a..3a65074 100644 --- 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 */ -- 2.7.4