]> granicus.if.org Git - gc/commitdiff
Fix last_reclaimed..gc_no interval comparison to threshold in unmap_old
authorIvan Maidanski <ivmai@mail.ru>
Sun, 14 Jan 2018 07:51:06 +0000 (10:51 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 19 Jan 2018 08:30:28 +0000 (11:30 +0300)
(fix commit 14c324f8b)

* allchblk.c [USE_MUNMAP] (GC_unmap_old): Replace
(unsigned short)GC_gc_no-hb_last_reclaimed to
(unsigned short)(GC_gc_no-hb_last_reclaimed) to handle
value wrapping in hb_last_reclaimed (and the truncated GC_gc_no)
correctly.

allchblk.c

index 41f22337c351c1b23db73bb6d107352488f0e508..4afb7de6d47d7400236e0b74698fe5d244e776da 100644 (file)
@@ -403,7 +403,9 @@ GC_INNER void GC_unmap_old(void)
         hhdr = HDR(h);
         if (!IS_MAPPED(hhdr)) continue;
 
-        if ((unsigned short)GC_gc_no - hhdr -> hb_last_reclaimed >
+        /* Check that the interval is larger than the threshold (the    */
+        /* truncated counter value wrapping is handled correctly).      */
+        if ((unsigned short)(GC_gc_no - hhdr->hb_last_reclaimed) >
                 (unsigned short)GC_unmap_threshold) {
           GC_unmap((ptr_t)h, hhdr -> hb_sz);
           hhdr -> hb_flags |= WAS_UNMAPPED;