summaryrefslogtreecommitdiff
path: root/malloc/malloc.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-11-15 11:39:01 +0100
committerFlorian Weimer <fweimer@redhat.com>2017-11-15 11:39:01 +0100
commit7a9368a1174cb15b9f1d6342e0e10dd90dae238d (patch)
tree635f3107419650143dd7139c12c01f9d43756bc3 /malloc/malloc.c
parentbe3a79a3cc8d8111811a52b0fe243b6f4dd03844 (diff)
malloc: Add missing arena lock in malloc_info [BZ #22408]
Obtain the size information while the arena lock is acquired, and only print it later.
Diffstat (limited to 'malloc/malloc.c')
-rw-r--r--malloc/malloc.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index f94d51cca1..0494e8c39f 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -5455,6 +5455,15 @@ __malloc_info (int options, FILE *fp)
avail += sizes[NFASTBINS - 1 + i].total;
}
+ size_t heap_size = 0;
+ size_t heap_mprotect_size = 0;
+ if (ar_ptr != &main_arena)
+ {
+ heap_info *heap = heap_for_ptr (top (ar_ptr));
+ heap_size = heap->size;
+ heap_mprotect_size = heap->mprotect_size;
+ }
+
__libc_lock_unlock (ar_ptr->mutex);
total_nfastblocks += nfastblocks;
@@ -5488,13 +5497,12 @@ __malloc_info (int options, FILE *fp)
if (ar_ptr != &main_arena)
{
- heap_info *heap = heap_for_ptr (top (ar_ptr));
fprintf (fp,
"<aspace type=\"total\" size=\"%zu\"/>\n"
"<aspace type=\"mprotect\" size=\"%zu\"/>\n",
- heap->size, heap->mprotect_size);
- total_aspace += heap->size;
- total_aspace_mprotect += heap->mprotect_size;
+ heap_size, heap_mprotect_size);
+ total_aspace += heap_size;
+ total_aspace_mprotect += heap_mprotect_size;
}
else
{