Commit Graph

625 Commits

Author SHA1 Message Date
Ondřej Bílka 0bfcf2c73c Remove assert in malloc statistic. Fixes bug 12486. 2013-10-18 09:35:15 +02:00
Will Newton 321e268471 malloc/hooks.c: Correct check for overflow in memalign_check.
A large value of bytes passed to memalign_check can cause an integer
overflow in _int_memalign and heap corruption. This issue can be
exposed by running tst-memalign with MALLOC_CHECK_=3.

ChangeLog:

2013-10-10  Will Newton  <will.newton@linaro.org>

	* malloc/hooks.c (memalign_check): Ensure the value of bytes
	passed to _int_memalign does not overflow.
2013-10-10 14:52:05 +01:00
Will Newton 66a9be9d58 malloc/tst-valloc.c: Tidy up code.
Add some comments and call free on all potentially allocated pointers.
Also remove duplicate check for NULL pointer.

ChangeLog:

2013-10-04  Will Newton  <will.newton@linaro.org>

	* malloc/tst-valloc.c: Add comments.
	(do_test): Add comments and call free on all potentially
	allocated pointers. Remove duplicate check for NULL pointer.
	Add space after cast.
2013-10-04 09:16:41 +01:00
Will Newton 1bc92709f3 malloc/tst-pvalloc.c: Tidy up code.
Add some comments and call free on all potentially allocated pointers.
Also remove duplicate check for NULL pointer.

ChangeLog:

2013-10-04  Will Newton  <will.newton@linaro.org>

	* malloc/tst-pvalloc.c: Add comments.
	(do_test): Add comments and call free on all potentially
	allocated pointers. Remove duplicate check for NULL pointer.
	Add space after cast.
2013-10-04 09:15:33 +01:00
Will Newton 27d0461b7b malloc/tst-posix_memalign.c: Tidy up code.
Add some comments and call free on all potentially allocated pointers.

ChangeLog:

2013-10-04  Will Newton  <will.newton@linaro.org>

	* malloc/tst-posix_memalign.c: Add comments.
	(do_test): Add comments and call free on all potentially
	allocated pointers. Add space after cast.
2013-10-04 09:14:27 +01:00
Will Newton 215c7d4344 malloc: Add memalign test.
ChangeLog:

2013-10-04  Will Newton  <will.newton@linaro.org>

    * malloc/Makefile: Add tst-memalign.
    * malloc/tst-memalign.c: New file.
2013-10-04 09:12:59 +01:00
Will Newton 3cef60098c malloc: Add pvalloc test.
ChangeLog:

2013-10-02  Will Newton  <will.newton@linaro.org>

	* malloc/Makefile: Add tst-pvalloc.
	* malloc/tst-pvalloc.c: New file.
2013-10-02 10:45:40 +01:00
Will Newton 7815420bc9 malloc/tst-valloc.c: Improve test coverage and use test-skeleton.c.
ChangeLog:

2013-10-02  Will Newton  <will.newton@linaro.org>

	* malloc/tst-valloc.c: Rewrite to use test-skeleton.c and
	improve test coverage.
2013-10-02 10:43:40 +01:00
Will Newton 4868b204aa malloc: Add posix_memalign test.
ChangeLog:

2013-10-02  Will Newton  <will.newton@linaro.org>

	* malloc/Makefile: Add tst-posix_memalign.
	* malloc/tst-posix_memalign.c: New file.
2013-10-02 10:42:36 +01:00
Alexandre Oliva 322dea0838 Add malloc probes for sbrk and heap resizing.
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-20 11:54:58 -03:00
Alexandre Oliva 655673f312 Add catch-all alloc retry probe.
for ChangeLog

	* malloc/arena.c (arena_get_retry): Add memory_arena_retry probe.
	* manual/probes.texi: Document it.
2013-09-20 11:50:51 -03:00
Alexandre Oliva 35fed6f15d Add probes for malloc retries.
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-20 11:50:08 -03:00
Alexandre Oliva 6999d38c95 Add probes for malloc arena changes.
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-20 11:48:45 -03:00
Alexandre Oliva 0653427fdb Add probes for all changes to malloc options.
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-20 11:42:28 -03:00
Alexandre Oliva 3ea5be5436 Add first set of memory probes.
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-20 11:10:54 -03:00
Will Newton b73ed24778 malloc: Check for integer overflow in memalign.
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-11 09:42:43 +01:00
Will Newton 55e17aadc1 malloc: Check for integer overflow in valloc.
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-11 09:41:04 +01:00
Will Newton 1159a19369 malloc: Check for integer overflow in pvalloc.
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-09-11 09:39:40 +01:00
Will Newton 0c66b8e985 malloc: Add realloc test.
The current tests don't test the functionality of realloc in detail.
Add a new test for realloc that exercises some of the corner cases
that are not otherwise tested.

ChangeLog:

2013-09-09  Will Newton  <will.newton@linaro.org>

	* malloc/Makefile: Add tst-realloc to tests.
	* malloc/tst-realloc.c: New file.
2013-09-09 09:20:09 +01:00
Ondřej Bílka 6f65e66895 Fix typos. 2013-08-29 09:11:45 +02:00
Joseph Myers 60d2f8f3c7 Use (void) in no-arguments function definitions. 2013-06-08 00:22:23 +00:00
Joseph Myers 2e09a79ada Avoid use of "register" as optimization hint. 2013-06-07 22:24:35 +00:00
Joseph Myers fab7ce3f5b Link extra-libs consistently with libc and ld.so. 2013-05-31 16:16:33 +00:00
Ryan S. Arnold e054f49430 Add #include <stdint.h> for uint[32|64]_t usage (except installed headers). 2013-05-16 11:32:54 -05:00
Peter Collingbourne 39b1f6172a Move _obstack_compat out of common
it is impossible to create an alias of a common symbol (as
compat_symbol does), because common symbols do not have a section or
an offset until linked.  GNU as tolerates aliases of common symbols by
simply creating another common symbol, but other assemblers (notably
LLVM's integrated assembler) are less tolerant.

2013-05-15  Peter Collingbourne  <pcc@google.com>

	* malloc/obstack.c (_obstack_compat): Add initializer.
-
2013-05-15 20:29:20 +02:00
Roland McGrath 0e2b9cdde7 BZ#14812: Add missing translation marker on some argp option argument names in utilities. 2013-03-18 14:59:47 -07:00
Joseph Myers a222d91a13 Remove __malloc_ptr_t. 2013-03-08 21:27:42 +00:00
Joseph Myers 5cc45e102b Use ISO C prototype for __default_morecore. 2013-03-08 16:47:43 +00:00
Joseph Myers dd54b8644c Remove __malloc_ptrdiff_t. 2013-03-08 16:46:45 +00:00
Joseph Myers 1ba4f03035 Remove __malloc_size_t. 2013-03-08 16:46:07 +00:00
Siddhesh Poyarekar 7da6d9ed26 Fix FPE in memusagestat when malloc utilization is zero
[BZ #15160]

Draw graphs for heap and stack only if MAXSIZE_HEAP and MAXSIZE_STACK
are non-zero.
2013-02-26 14:24:40 +05:30
Pino Toscano 2a26ef3a01 Add HAVE_MREMAP for mremap usage
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-17 21:08:12 +01:00
H.J. Lu 740b3dbee8 Add --enable-hardcoded-path-in-tests configure option 2013-01-11 07:14:18 -08:00
Joseph Myers 375607b9cc Clean up __MALLOC_* macros. 2013-01-07 15:00:47 +00:00
Andreas Schwab 2f5f40f465 mtrace: properly handle realloc (p, 0) 2013-01-03 11:18:04 +01:00
Joseph Myers 568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Joseph Myers f4cf5f2d8b Add script to update copyright notices and reformat some to facilitate its use. 2013-01-01 16:29:10 +00:00
David S. Miller 0549fbba96 Update copyright years.
* catgets/gencat.c: Update copyright year.
	* csu/version.c: Likewise.
	* debug/catchsegv.sh: Likewise.
	* debug/pcprofiledump.c: Likewise.
	* debug/xtrace.sh: Likewise.
	* elf/ldconfig.c: Likewise.
	* elf/ldd.bash.in: Likewise.
	* elf/pldd.c: Likewise.
	* elf/sotruss.ksh: Likewise.
	* elf/sprof.c: Likewise.
	* iconv/iconv_prog.c: Likewise.
	* iconv/iconvconfig.c: Likewise.
	* locale/programs/locale.c: Likewise.
	* locale/programs/localedef.c: Likewise.
	* login/programs/pt_chown.c: Likewise.
	* malloc/memusage.sh: Likewise.
	* malloc/memusagestat.c: Likewise.
	* malloc/mtrace.pl: Likewise.
	* nscd/nscd.c: Likewise.
	* nss/getent.c: Likewise.
	* nss/makedb.c: Likewise.
	* posix/getconf.c: Likewise.
2013-01-01 00:11:43 -08:00
Pino Toscano e19af3803b muntrace: reset file and hooks before finalizing the stream
fclose will call free, invoking its hook, then fprintf which would indirectly
try to allocate a buffer, and this can cause malloc to be used (thus its hook
to be invoked) if libio uses malloc instead of mmap; given any malloc/free hook
locks the internal lock, this leads to a deadlock.

To prevent this hook roundtrip at muntrace, first unset MALLSTREAM and the
hooks, and only after that close the trace file.
2012-11-19 20:01:00 +01:00
Joseph Myers e3ea54090a Update --version copyright dates for memusagestat and pcprofiledump. 2012-11-15 01:01:33 +00:00
Joseph Myers 8b748aed2a Support --with-pkgversion and --with-bugurl. 2012-11-09 22:13:45 +00:00
Joseph Myers 03ac099f6b Define and use $(run-built-tests). 2012-10-24 00:08:46 +00:00
Joseph Myers e40a0d2113 Use $(run-program-prefix) in more shell script tests. 2012-10-19 23:30:43 +00:00
Roland McGrath 9043e2288e Name space hygeine for madvise. 2012-10-04 16:31:43 -07:00
Dmitry V. Levin bb9510dc34 Clarify memory allocation error diagnostics to avoid confusion 2012-10-02 16:09:30 +00:00
Siddhesh Poyarekar 9fab36eb58 Shrink heap on linux when overcommit_memory == 2
Using madvise with MADV_DONTNEED to release memory back to the kernel
is not sufficient to change the commit charge accounted against the
process on Linux.  It is OK however, when overcommit is enabled or is
heuristic.  However, when overcommit is restricted to a percentage of
memory setting the contents of /proc/sys/vm/overcommit_memory as 2, it
makes a difference since memory requests will fail.  Hence, we do what
we do with secure exec binaries, which is to call mmap on the region
to be dropped with MAP_FIXED. This internally unmaps the pages in
question and reduces the amount of memory accounted against the
process.
2012-09-25 14:30:52 +05:30
Dmitry V. Levin 57c69bef13 Set "fail on error" mode directly in testsuite shell scripts 2012-09-25 02:48:31 +00:00
H.J. Lu ced6f16ee9 Properly handle fencepost with MALLOC_ALIGN_MASK 2012-09-24 08:58:04 -07:00
Siddhesh Poyarekar c78ab09473 Cleanup code duplication in malloc on fallback to use another arena
Break the fallback code to try another arena into a separate function
for readability.
2012-09-07 14:40:58 +05:30
Alexandre Oliva 24d4e01b22 * malloc/arena.c: Fold copyright years.
* malloc/mcheck.c, malloc/memusage.c: Likewise.
2012-09-05 20:47:16 -03:00
Alexandre Oliva 61d5817416 * malloc/malloc.c (__libc_mallopt) <M_MMAP_MAX>: Fix indentation. 2012-09-05 20:37:37 -03:00
Alexandre Oliva 5c44738353 Don't change no_dyn_threshold on mallopt failure
* malloc/malloc.c (__libc_mallopt) <M_MMAP_THRESHOLD>: Do not
	change internal state upon failure.
2012-09-05 15:43:04 -03:00
Alexandre Oliva fad64255f4 Fix typos in malloc/.
* malloc/mcheck.c (mcheck_check_all): Fix typo.
	* malloc/memusage.c (mmap): Likewise.
	(mmap64, mremap): Likewise.  Adjust name in comment.
2012-09-05 15:19:44 -03:00
Siddhesh Poyarekar 6ef9cc37f0 Return requested size for malloc_usable_size when MALLOC_CHECK_ > 0
[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-09-05 21:49:30 +05:30
Roland McGrath 750c1f2a9a Make malloc build for no-threads configurations. 2012-08-17 11:29:45 -07:00
Jeff Law 77480c6ba5 Fix whitespace problems detected by commit hooks. 2012-08-10 09:39:58 -06:00
Jeff Law bf51f568f1 [BZ #13939]
* malloc.c/arena.c (reused_arena): New parameter, avoid_arena.
        When avoid_arena is set, don't retry in the that arena.  Pick the
        next one, whatever it might be.
        (arena_get2): New parameter avoid_arena, pass through to reused_arena.
        (arena_lock): Pass in new parameter to arena_get2.
        * malloc/malloc.c (__libc_memalign): Pass in new parameter to
        arena_get2.
        (__libc_malloc): Unify retrying after main arena failure with
        __libc_memalign version.
        (__libc_valloc, __libc_pvalloc, __libc_calloc): Likewise.
2012-08-10 09:37:52 -06:00
Florian Weimer 84b3fd8407 Rename __secure_getenv to secure_getenv 2012-07-25 19:46:22 +02:00
H.J. Lu 347c92e9e7 Make free chunk size a multiple of MALLOC_ALIGNMENT 2012-05-24 17:50:28 -07:00
Andreas Schwab d18ea0c5e6 Remove use of INTDEF/INTUSE in libio 2012-05-24 23:06:20 +02:00
H.J. Lu b5a2bbe6cc Properly handle MALLOC_ALIGNMENT > 2 * SIZE_SZ 2012-05-24 11:57:23 -07:00
Andreas Jaeger 662742187c Fix last change
Include shlib-compat.h for SHLIB_COMPAT.
2012-05-21 21:02:33 +02:00
Roland McGrath cbc00a0398 Set MALLOC_ALIGNMENT to at least __alignof__ (long double) for new ABIs. 2012-05-21 11:13:10 -07:00
Paul Pluzhnikov bedee953d8 For [BZ #208], accumulate malloc stats over all arenas. 2012-05-16 16:46:10 -07:00
Andreas Jaeger f0c1dedf0d Fix tst-obprintf - and mcheck in general
tst-obprintf failed with GCC 4.7.

It turned out that this is the fault of GCC optimizing away the
following from malloc/mcheck.c:
      /* We call malloc() once here to ensure it is initialized.  */
      void *p = malloc (0);
      free (p);

gcc sees the malloc(0);free pair and removes it completely.

And now malloc is not properly initialized and we screw up if both
mcheck is used (via tst-obprintf) and MALLOC_CHECK_ is set (as it is in my
environment).
2012-05-03 22:12:59 +02:00
Ulrich Drepper 05f3d1f6c6 Avoid warnings in test malloc program 2012-03-28 13:05:11 -04:00
H.J. Lu eb96ffb07d Move stdio-common/_itoa.h to sysdeps/generic 2012-03-20 16:00:23 -07:00
Ulrich Drepper a4300c7a4d Remove distribute variable from Makefiles 2012-03-07 05:17:13 -05:00
Paul Eggert 59ba27a63a Replace FSF snail mail address with URLs. 2012-02-09 23:18:22 +00:00
Ulrich Drepper 3b49edc04b Cleanups of malloc
Remove ugly names and unnecessary wrappers.
2012-01-31 18:49:22 -05:00
Ulrich Drepper 41b81892f1 Handle ARENA_TEST correctly 2012-01-31 14:42:34 -05:00
Joseph Myers 7071ad79db Remove __STDC__ conditionals from installed headers. 2012-01-26 20:49:22 +00:00
Ulrich Drepper 6e4b210745 More minor malloc cleanups 2012-01-17 19:21:09 -05:00
Ulrich Drepper d77e786926 Minor cleanups of malloc code 2012-01-16 12:07:56 -05:00
Ulrich Drepper a784e50247 Remove pre-ISO C support
No more __const.
2012-01-07 23:57:22 -05:00
Ulrich Drepper 380d7e87dc Implement aligned_alloc 2012-01-01 07:17:21 -05:00
Ulrich Drepper 81fb02b046 Update copyright year 2012-01-01 05:50:05 -05:00
Ulrich Drepper 4104316861 Optimize tr_freehook 2011-12-22 11:38:32 -05:00
Ulrich Drepper 8a426e1289 Fix comment in mcheck.h 2011-12-03 07:14:40 -05:00
Andreas Schwab a5fb313cb7 Don't call reused_arena when _int_new_arena failed 2011-11-14 11:53:46 +01:00
Andreas Schwab 77cdc054e0 Check malloc arana limit atomically 2011-11-10 11:00:59 +01:00
Ulrich Drepper 6ef76f3b51 Avoid assertion in processes with VM in bad shape 2011-10-29 16:39:03 -04:00
Ulrich Drepper 633f745dca Avoid cast in non-gcc obstack_free 2011-09-11 13:04:17 -04:00
Ulrich Drepper 8e58439c92 Remove MALLOC_FAILURE_ACTION use in malloc 2011-09-10 22:12:38 -04:00
Ulrich Drepper 02d46fc4b9 Simplify malloc initialization
Singificantly reduce the code needed at malloc initialization.  In
the process getpagesize is simplified by always initializing
GLRO(dl_pagesize).
2011-09-10 21:47:36 -04:00
Ulrich Drepper 22a8918713 Simplify malloc code
Remove all kinds of unused configuration options and dead code.
2011-09-10 18:10:17 -04:00
Ulrich Drepper d063d16433 Remove support for !USE___THREAD 2011-09-10 16:50:28 -04:00
Ulrich Drepper 3ce1f29594 Cleanup of configuration options
Make several tool features mandatory and simplify the code.
2011-09-10 14:34:15 -04:00
Ulrich Drepper 8538fdb3ec (memalign_check): No need to use checked_request2size. 2011-07-08 13:20:41 -04:00
Ulrich Drepper 5c0b8d9013 Fix quoting in some installed shell scripts 2011-06-28 18:14:01 -04:00
Ulrich Drepper 9113ea1f3f Remove the --experimental-malloc option
It's well tested, make it the default.
2011-06-28 16:53:01 -04:00
Ulrich Drepper 7d17596c19 Mark malloc hook variables as deprecated 2011-05-29 21:10:23 -04:00
Ulrich Drepper a33c44639a Perhaps the real definition of __MALLOC_HOOK_VOLATILE should be added 2011-05-29 20:43:54 -04:00
Ulrich Drepper 0810a11e53 Missed one malloc hook variable 2011-05-29 20:41:09 -04:00
Ulrich Drepper cf6bbbd701 Declare malloc hook variables as volatile. 2011-05-29 20:40:08 -04:00
Ulrich Drepper de81b24662 Unify messages
Some shell scripts unnecessarily used different formats for some
messages.  Unify them to reduce the work of translators.
2011-05-28 09:49:05 -04:00
Ulrich Drepper 56e5eb4619 Avoid potential deadlock in mtrace
The _dl_addr function might have to call malloc which would lead
to a deadlock.  Avoid by calling _dl_addr early.
2011-05-16 00:58:33 -04:00
Ulrich Drepper 6ce7537960 Remove USE_MTRACE_FILE support from mtrace 2011-05-16 00:22:16 -04:00
Jim Meyering ded5b9b7c7 Remove doubled words. 2011-04-22 21:34:32 -04:00
Ulrich Drepper c0dafcf176 Update copyright year. 2011-01-17 15:08:10 -05:00