aboutsummaryrefslogtreecommitdiff
path: root/malloc/malloc.c
AgeCommit message (Collapse)Author
2014-09-11malloc: additional unlink hardening for non-small bins [BZ #17344]Florian Weimer
Turn two asserts into a conditional call to malloc_printerr. The memory locations are accessed later anyway, so the performance impact is minor.
2014-08-12malloc: fix comment typoSean Anderson
2014-06-19malloc/malloc.c: Avoid calling sbrk unnecessarily with zeroWill Newton
Due to my bad review suggestion for the fix for BZ #15089 a check was removed from systrim to prevent sbrk being called with a zero argument. Add the check back to avoid this useless work. ChangeLog: 2014-06-19 Will Newton <will.newton@linaro.org> * malloc/malloc.c (systrim): If extra is zero then return early.
2014-06-02Fix format specifier for n_mmapsSiddhesh Poyarekar
2014-05-30Fix formatting in malloc_infoSiddhesh Poyarekar
2014-05-30Add mmap usage in malloc_info outputSiddhesh Poyarekar
The current malloc_info xml output only has information about allocations on the heap. Display information about number of mappings and total mmapped size to this to complete the picture.
2014-05-30Remove mi_arena nested function.Ondřej Bílka
2014-05-30revert commit fdfd175d46ac6a810ebdeb2a2936e6d7d13995abOndřej Bílka
2014-05-26Remove nested function mi_arena from malloc_info.Carlos O'Donell
The nested function mi_arena was removed from malloc_info and made into a non-nested static inline function of the same name with the correct set of arguments passed from malloc_info. This enables building glibc with compilers that don't support nested functions. Future work on malloc_info should remove these functions entirely to support JSON format output. Therefore we do the minimum required to remove the nested function.
2014-04-11malloc: Fix MALLOC_DEBUG -Wundef warningWill Newton
MALLOC_DEBUG is set optionally on the command line. Default the value to zero if it is not set on the command line, and test its value with #if rather than #ifdef. Verified the code is identical before and after this change apart from line numbers. ChangeLog: 2014-04-11 Will Newton <will.newton@linaro.org> * malloc/malloc.c [!MALLOC_DEBUG]: #define MALLOC_DEBUG to zero if it is not defined elsewhere. (mtrim): Test the value of MALLOC_DEBUG with #if rather than #ifdef.
2014-03-03Revert 4248f0da6ff9e7dd63464cdecec2dec332dfc2f0.Carlos O'Donell
Objections were raised surrounding the calloc simplification and it is better to revert the patch, continue discussions and then submit a new patch for inclusion with all issues fully addressed.
2014-02-26Simplify calloc implementation.Ondřej Bílka
To make future improvements of allocator simpler we could for now calloc just call malloc and memset. With that we could omit a changes that would duplicate malloc changes anyway.
2014-02-10Use glibc_likely instead __builtin_expect.Ondřej Bílka
2014-02-10Remove THREAD_STATS.Ondřej Bílka
A THREAD_STATS macro duplicates gathering information that could be obtained by systemtap probes instead.
2014-01-02Reformat malloc to gnu style.Ondřej Bílka
2014-01-01Update copyright notices with scripts/update-copyrightsAllan McRae
2013-12-24Fix race in free() of fastbin chunk: BZ #15073Maxim Kuvyrkov
Perform sanity check only if we have_lock. Due to lockless nature of fastbins we need to be careful derefencing pointers to fastbin entries (chunksize(old) in this case) in multithreaded environments. The fix is to add have_lock to the if-condition checks. The rest of the patch only makes code more readable. * malloc/malloc.c (_int_free): Perform sanity check only if we have_lock.
2013-12-10Expand MALLOC_COPY and MALLOC_ZERO to memcpy and memset.Ondřej Bílka
2013-12-10Drop PER_THREAD conditionals from malloc.Ondřej Bílka
2013-12-09Simplify perturb_byte logic.Ondřej Bílka
2013-12-09Replace malloc force_reg by atomic_forced_read.Ondřej Bílka
2013-12-06Fix BZ #15089: malloc_trim always trim for large padding.Fernando J. V. da Silva
2013-11-28Make memset in calloc a tail call.Ondřej Bílka
2013-11-21Add missing #include for malloc/hooks.c code.Roland McGrath
2013-11-20Consolidate valloc/pvalloc code.Ondřej Bílka
To make malloc code more maintainable we make malloc and pvalloc share logic with memalign.
2013-11-01Fix malloc_info statistic. Fixes bug 16112Ondřej Bílka
2013-10-30malloc: Fix for infinite loop in memalign/posix_memalign.Will Newton
A very large alignment argument passed to mealign/posix_memalign causes _int_memalign to enter an infinite loop. Limit the maximum alignment value to the maximum representable power of two to prevent this from happening. Changelog: 2013-10-30 Will Newton <will.newton@linaro.org> [BZ #16038] * malloc/hooks.c (memalign_check): Limit alignment to the maximum representable power of two. * malloc/malloc.c (__libc_memalign): Likewise. * malloc/tst-memalign.c (do_test): Add test for very large alignment values. * malloc/tst-posix_memalign.c (do_test): Likewise.
2013-10-30Use atomic operations to track memory. Fixes bug 11087Ondřej Bílka
2013-10-18Remove assert in malloc statistic. Fixes bug 12486.Ondřej Bílka
2013-09-20Add malloc probes for sbrk and heap resizing.Alexandre Oliva
for ChangeLog * malloc/arena.c (new_heap): New memory_heap_new probe. (grow_heap): New memory_heap_more probe. (shrink_heap): New memory_heap_less probe. (heap_trim): New memory_heap_free probe. * malloc/malloc.c (sysmalloc): New memory_sbrk_more probe. (systrim): New memory_sbrk_less probe. * manual/probes.texi: Document them.
2013-09-20Add probes for malloc retries.Alexandre Oliva
for ChangeLog * malloc/malloc.c (__libc_malloc): Add memory_malloc_retry probe. (__libc_realloc): Add memory_realloc_retry probe. (__libc_memalign): Add memory_memalign_retry probe. (__libc_valloc): Add memory_valloc_retry probe. (__libc_pvalloc): Add memory_pvalloc_retry probe. (__libc_calloc): Add memory_calloc_retry probe. * manual/probes.texi: Document them.
2013-09-20Add probes for malloc arena changes.Alexandre Oliva
for ChangeLog * malloc/arena.c (get_free_list): Add probe memory_arena_reuse_free_list. (reused_arena) [PER_THREAD]: Add probes memory_arena_reuse_wait and memory_arena_reuse. (arena_get2) [!PER_THREAD]: Likewise. * malloc/malloc.c (__libc_realloc) [!PER_THREAD]: Add probe memory_arena_reuse_realloc. * manual/probes.texi: Document them.
2013-09-20Add probes for all changes to malloc options.Alexandre Oliva
for ChangeLog * malloc/malloc.c (__libc_free): Add memory_mallopt_free_dyn_thresholds probe. (__libc_mallopt): Add multiple memory_mallopt probes. * manual/probes.texi: Document them.
2013-09-20Add first set of memory probes.Alexandre Oliva
for ChangeLog * malloc/malloc.c: Include stap-probe.h. (__libc_mallopt): Add memory_mallopt probe. * malloc/arena.c (_int_new_arena): Add memory_arena_new probe. * manual/probes.texi: New. * manual/Makefile (chapters): Add probes. * manual/threads.texi: Set next node.
2013-09-11malloc: Check for integer overflow in memalign.Will Newton
A large bytes parameter to memalign could cause an integer overflow and corrupt allocator internals. Check the overflow does not occur before continuing with the allocation. ChangeLog: 2013-09-11 Will Newton <will.newton@linaro.org> [BZ #15857] * malloc/malloc.c (__libc_memalign): Check the value of bytes does not overflow.
2013-09-11malloc: Check for integer overflow in valloc.Will Newton
A large bytes parameter to valloc could cause an integer overflow and corrupt allocator internals. Check the overflow does not occur before continuing with the allocation. ChangeLog: 2013-09-11 Will Newton <will.newton@linaro.org> [BZ #15856] * malloc/malloc.c (__libc_valloc): Check the value of bytes does not overflow.
2013-09-11malloc: Check for integer overflow in pvalloc.Will Newton
A large bytes parameter to pvalloc could cause an integer overflow and corrupt allocator internals. Check the overflow does not occur before continuing with the allocation. ChangeLog: 2013-09-11 Will Newton <will.newton@linaro.org> [BZ #15855] * malloc/malloc.c (__libc_pvalloc): Check the value of bytes does not overflow.
2013-08-29Fix typos.Ondřej Bílka
2013-06-08Use (void) in no-arguments function definitions.Joseph Myers
2013-03-08Remove __malloc_ptr_t.Joseph Myers
2013-01-17Add HAVE_MREMAP for mremap usagePino Toscano
Introduce (only on Linux) and use a HAVE_MREMAP symbol to advertize mremap availability. Move the malloc-sysdep.h include from arena.c to malloc.c, since what is provided by malloc-sysdep.h is needed earlier in malloc.c, before the inclusion of arena.c.
2013-01-07Clean up __MALLOC_* macros.Joseph Myers
2013-01-02Update copyright notices with scripts/update-copyrights.Joseph Myers
2012-10-04Name space hygeine for madvise.Roland McGrath
2012-10-02Clarify memory allocation error diagnostics to avoid confusionDmitry V. Levin
2012-09-07Cleanup code duplication in malloc on fallback to use another arenaSiddhesh Poyarekar
Break the fallback code to try another arena into a separate function for readability.
2012-09-05* malloc/malloc.c (__libc_mallopt) <M_MMAP_MAX>: Fix indentation.Alexandre Oliva
2012-09-05Don't change no_dyn_threshold on mallopt failureAlexandre Oliva
* malloc/malloc.c (__libc_mallopt) <M_MMAP_THRESHOLD>: Do not change internal state upon failure.
2012-09-05Return requested size for malloc_usable_size when MALLOC_CHECK_ > 0Siddhesh Poyarekar
[BZ #1349] malloc_usable_size returns the usable size in an allocated chunk, which may be >= the requested size. In the case of MALLOC_CHECK_ being exported to > 0 however, only the requested size is usable, since a magic value is written at the end of the request size to trap writes beyond request bounds. Hence, when MALLOC_CHECK_ is exported to > 0, malloc_usable_size() should return the request size.
2012-08-17Make malloc build for no-threads configurations.Roland McGrath