From: Ivan Maidanski Date: Sun, 14 Jan 2018 07:51:06 +0000 (+0300) Subject: Fix last_reclaimed..gc_no interval comparison to threshold in unmap_old X-Git-Tag: v7.4.10~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a7129ab4e4e40b435fd1835b2a728a11f449b8c5;p=gc Fix last_reclaimed..gc_no interval comparison to threshold in unmap_old (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. --- diff --git a/allchblk.c b/allchblk.c index 41f22337..4afb7de6 100644 --- a/allchblk.c +++ b/allchblk.c @@ -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;