This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/6952] malloc is not thread-safe

------- Additional Comments From axel dot philipp at mtu dot de  2009-02-06 13:03 -------
Created an attachment (id=3722)
 --> (
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
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

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|                            |

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]