1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-06-13 19:21:36 +03:00

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.
This commit is contained in:
Florian Weimer
2017-11-15 11:39:01 +01:00
parent be3a79a3cc
commit 7a9368a117
4 changed files with 124 additions and 4 deletions

View File

@ -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
{