yodamaster / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

tcmalloc will coredump if I free memory at fork (with library dlopened with RTLD_DEEPBIND) #566

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. write a shared library,and load it with flag RTLD_NOW | RTLD_LOCAL | 
RTLD_DEEPBIND 
2. write a loop function in the shared library, repeat malloc/write/free memory 
frequently
3. fork child process frequently at main program
4. compile and link tcmalloc 
5. if I don't link tcmalloc, my program will work normally

What is the expected output? What do you see instead?

after a short while, our program will coredump , core stack info:

#3  0x000000302af2e2ed in raise () from /lib64/tls/libc.so.6
#4  0x000000302af2fa3e in abort () from /lib64/tls/libc.so.6
#5  0x000000302af62db1 in __libc_message () from /lib64/tls/libc.so.6
#6  0x000000302af6888e in _int_free () from /lib64/tls/libc.so.6
#7  0x000000302af68af0 in free_atfork () from /lib64/tls/libc.so.6
#8  0x00007f5842d8fa7b in bsl::pool_allocator<char>::deallocate 
(this=0x7f584138a9d0, __p=0x91ffa0 "sample_variable", size_=16)
    at ../../output/include/bsl/pool/bsl_poolalloc.h:129

What version of the product are you using? On what operating system?

google-perftools-1.7
gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)
kernel: 2.6.32_1-7-0-0

Please provide any additional information below.

Original issue reported on code.google.com by leywar.l...@gmail.com on 22 Aug 2013 at 11:53

GoogleCodeExporter commented 9 years ago
still can reproduce it in  gpreftools 2.1

Original comment by leywar.l...@gmail.com on 23 Aug 2013 at 12:41

GoogleCodeExporter commented 9 years ago
Backtrace above hinted me towards this: 
http://repo.or.cz/w/glibc.git/blob/eefa3be8e4c2c721a9f277d8ea2e11180231829f:/mal
loc/arena.c#l224

It looks like glibc malloc will install it's "special" version of malloc/free 
hooks.

And gperftools comment here: 
https://code.google.com/p/gperftools/source/browse/src/libc_override_glibc.h#98 
refers to DEEPBIND overriding tcmalloc's overriding of malloc/free.

I'm not super-familiar with how exactly DEEPBIND may cause issues. So in order 
to understand your case more I need to know exactly how your program is 
integrated to tcmalloc.

Particularly:

* is your program linked with tcmalloc or it's LD_PRELOAD-ed ?

* is your "shared library" linked with tcmalloc ?

Original comment by alkondratenko on 29 Aug 2013 at 1:34

GoogleCodeExporter commented 9 years ago

Original comment by alkondratenko on 29 Aug 2013 at 1:35