This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/6952] malloc is not thread-safe
- From: "axel dot philipp at mtu dot de" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 6 Feb 2009 13:03:19 -0000
- Subject: [Bug libc/6952] malloc is not thread-safe
- References: <20081008091818.6952.axel.philipp@mtu.de>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From axel dot philipp at mtu dot de 2009-02-06 13:03 -------
Created an attachment (id=3722)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=3722&action=view)
improved test case which makes it easier to reproduce the effect
With our real world example there is a striking dependence on RLIMIT_STACK. If
the stacklimit is either low (SuSE default 8192) or unlimited, the memory leak
is very pronounced, if the limit is 512 MB (ulimit -s 524288) it takes several
attempts to reproduce the problem.
The stacklimit has almost no influence on my small example, but if I omit the
usleeps (second parameter 0), it may take dozens of runs to reproduce the
problem.
I have modified my example, so that two or three runs should be sufficient to
reproduce the problem. You will need a system with at least two quadcore or
four dualcore processors.
The example is compiled with:
gcc -l pthread -o malloc_thread_test_pa malloc_thread_test_pa.c
If you want to watch the program you should run top -d 1 in a second window.
Another way is to run it in a loop, my program now outputs the peak RSS:
while true; do
malloc_thread_test_pa 2>/dev/null
done
If I run malloc_thread_test_pa 8 0 instead, ist nearly impossible to reproduce
the problem.
That's how the output should look like:
loop 0: VmHWM: 3080068 kB
loop 1: VmHWM: 3080188 kB
loop 2: VmHWM: 3080188 kB
loop 3: VmHWM: 3080188 kB
loop 4: VmHWM: 3080188 kB
loop 5: VmHWM: 3080188 kB
loop 6: VmHWM: 3080188 kB
loop 7: VmHWM: 3080188 kB
loop 8: VmHWM: 3080188 kB
loop 9: VmHWM: 3080188 kB
and that's what I typically get:
loop 0: VmHWM: 3079520 kB
loop 1: VmHWM: 3464160 kB
loop 2: VmHWM: 3464160 kB
loop 3: VmHWM: 3464280 kB
loop 4: VmHWM: 3464280 kB
loop 5: VmHWM: 3464280 kB
loop 6: VmHWM: 3849292 kB
loop 7: VmHWM: 3849292 kB
loop 8: VmHWM: 3849292 kB
loop 9: VmHWM: 3849292 kB
--
What |Removed |Added
----------------------------------------------------------------------------
Attachment #2986 is|0 |1
obsolete| |
Attachment #3002 is|0 |1
obsolete| |
http://sourceware.org/bugzilla/show_bug.cgi?id=6952
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.