Skip to content

Commit

Permalink
malloc: Test various special cases related to allocation failures
Browse files Browse the repository at this point in the history
This test case exercises unusual code paths in allocation functions,
related to allocation failures.  Specifically, the test can reveal
the following bugs:

(a) calloc returns non-zero memory on fallback to sysmalloc.
(b) calloc can self-deadlock because it fails to release
    the arena lock on certain allocation failures.
(c) pvalloc can dereference a NULL arena pointer.

(a) and (b) appear specific to a faulty downstream backport.
(c) was fixed as part of commit 10ad46b.

The test for (a) was inspired by a reproducer supplied by Jeff Layton.
  • Loading branch information
Florian Weimer committed Dec 29, 2015
1 parent b69b5b3 commit 1bd5483
Show file tree
Hide file tree
Showing 3 changed files with 452 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2015-12-29 Florian Weimer <fweimer@redhat.com>

* malloc/tst-malloc-thread-fail.c: New file.
* malloc/Makefile (tests): Add tst-malloc-thread-fail.
(tst-malloc-thread-fail): Link against libpthread.

2015-12-29 Mike Frysinger <vapier@gentoo.org>

* scripts/list-fixed-bugs.py: Import argparse. Call main instead.
Expand Down
5 changes: 4 additions & 1 deletion malloc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
tst-mallocstate tst-mcheck tst-mallocfork tst-trim1 \
tst-malloc-usable tst-realloc tst-posix_memalign \
tst-pvalloc tst-memalign tst-mallopt tst-scratch_buffer \
tst-malloc-backtrace tst-malloc-thread-exit
tst-malloc-backtrace tst-malloc-thread-exit \
tst-malloc-thread-fail
test-srcs = tst-mtrace

routines = malloc morecore mcheck mtrace obstack \
Expand All @@ -49,6 +50,8 @@ $(objpfx)tst-malloc-backtrace: $(common-objpfx)nptl/libpthread.so \
$(common-objpfx)nptl/libpthread_nonshared.a
$(objpfx)tst-malloc-thread-exit: $(common-objpfx)nptl/libpthread.so \
$(common-objpfx)nptl/libpthread_nonshared.a
$(objpfx)tst-malloc-thread-fail: $(common-objpfx)nptl/libpthread.so \
$(common-objpfx)nptl/libpthread_nonshared.a

# These should be removed by `make clean'.
extra-objs = mcheck-init.o libmcheck.a
Expand Down
Loading

0 comments on commit 1bd5483

Please sign in to comment.