krime / gperftools

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

Why tcmalloc fail when I compile run program with shared library? #697

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
0. download all attached files into some_directory, and $cd some_directory
1. $ mkdir shared_libs
2. $ make
3. $ make run

What is the expected output?
Memory leak detected in shared.cpp:9

What do you see instead?
"No live heap object at 0x2582aa0 to ignore
Check failed: heap_profile->FindAlloc(test_str, &size): our own new/delete not 
linked?
Aborted (core dumped)"

On my ubuntu 14.04

"No leaks found for check "_main_" (but no 100% guarantee that there aren't 
any): found 7 reachable heap objects of 107 bytes"

On my linux Mint

What version of the product are you using? On what operating system?
version: gperftools-2.4

Original issue reported on code.google.com by Dima00...@gmail.com on 1 Jul 2015 at 7:06

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for reporting it. It looks like on ubuntu your code that
doesn't call malloc/new from main.cpp is causing linked not to link
libtcmalloc.so to ./a.out. I.e. you can see it by doing ldd ./a.out.
It is not how it's supposed to work (and not how it works on my debian
box either).

As a result of this tcmalloc is loaded together with your shared
object which is too late and not supported.

You can work around this "initiative" (which is as usual, clearly,
result of good intentions) by adding -Wl,--no-as-needed before
-ltcmalloc when you build your main executable.

Marking as "wont fix" since it's not our fault here. I think. Feel free to 
reopen if you have arguments against this.

Original comment by alkondratenko on 2 Jul 2015 at 7:05