This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/4630] New: assertion failure in do_check_malloc_state caused by the non-continuous case in sysMALLOc()
- From: "philipp dot tomsich at theobroma-systems dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 12 Jun 2007 14:26:07 -0000
- Subject: [Bug libc/4630] New: assertion failure in do_check_malloc_state caused by the non-continuous case in sysMALLOc()
- Reply-to: sourceware-bugzilla at sourceware dot org
We've hit the assertion "malloc.c:2884: do_check_malloc_state: Assertion `(unsigned long)(av-
>system_mem) <= (unsigned long)(av->max_system_mem)' failed." with glibc-2.6 (with
MALLOC_DEBUG defined to 1) on Linux 2.6.
Our application frequently uses sbrk()/mmap() directly and exercises the non-continuous case in
sYSMALLOc(). In rare cases, do_check_malloc_state() will be called through _int_free() at malloc.c:3333
with (av->system_mem) > (av->max_system_mem), when av->system_mem is increased in
sYSMALLOc at malloc.c:3299, malloc.c:3232 and malloc.c:3188.
I'm including a patch to adjust av->max_system_mem to a consistent malloc state (earlier than at
malloc.c:3352) if _int_free() will be called. The patch will introduce no overhead if MALLOC_DEBUG is
not defined.
--- glibc-2.6-vanilla/malloc/malloc.c 2007-05-15 03:51:17.000000000 +0200
+++ glibc-2.6/malloc/malloc.c 2007-06-12 16:05:48.000000000 +0200
@@ -3330,6 +3330,17 @@
/* If possible, release the rest. */
if (old_size >= MINSIZE) {
+
+#if MALLOC_DEBUG
+ /* Restore a consistent state early to avoid failures with
+ debug builds _int_free() calls sYSTRIm() (and sYSTRIm()
+ asserts on inconistencies) */
+
+ if ((unsigned long)(av->system_mem) >
+ (unsigned long)(av->max_system_mem))
+ av->max_system_mem = av->system_mem;
+#endif
+
_int_free(av, chunk2mem(old_top));
}
--- glibc-2.6-vanilla/ChangeLog 2007-05-15 08:49:29.000000000 +0200
+++ glibc-2.6/ChangeLog 2007-06-12 16:04:55.000000000 +0200
@@ -0,0 +1,7 @@
+2007-06-12 Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
+
+ * malloc/malloc.c (sYSMALLOc): Added an early adjustment
+ (conditional to DEBUG_MALLOC) of av->max_system_mem for the
+ non-continuous case to avoid triggering an assertion in
+ check_malloc_state().
+
--
Summary: assertion failure in do_check_malloc_state caused by the
non-continuous case in sysMALLOc()
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: philipp dot tomsich at theobroma-systems dot com
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: i686-linux-gnu
GCC host triplet: mipsel-linux-gnu
GCC target triplet: mipsel-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=4630
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.