[RFC,1/4] malloc_info: mask out status bits when reporting chunk sizes [BZ #17039]

Message ID 8c36e0cc-e045-2670-9af1-4df8abc27e79@gmail.com
State New, archived
Headers

Commit Message

Ken Milmore May 24, 2018, 12:10 a.m. UTC
  When generating statistics for malloc_info(), use chunksize() instead of
chunksize_nomask() to ensure the flag bits are stripped from the LSBs
of free chunk sizes. Previously, the flag bits were contributing a few
bytes of error per chunk, which could add up to a sizeable error when
summed together across the entire heap.

	[BZ #17039]
	* malloc/malloc.c (__malloc_info): Mask out status bits when
	reporting chunk sizes.
---
 malloc/malloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 9614954975..c0f1b26e1e 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -5467,7 +5467,7 @@  __malloc_info (int options, FILE *fp)
 	  if (r != NULL)
 	    while (r != bin)
 	      {
-		size_t r_size = chunksize_nomask (r);
+		size_t r_size = chunksize (r);
 		++sizes[NFASTBINS - 1 + i].count;
 		sizes[NFASTBINS - 1 + i].total += r_size;
 		sizes[NFASTBINS - 1 + i].from