casseopea2 / gperftools

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

Can't using tcmalloc with emacs and others #148

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install Debian-5 + compile emacs-23 (CFLAGS=-O2 -fomit-frame-pointer
-momit-leaf-frame-pointer -march=x86-64 -finline-functions) AND tcmalloc
(with --disable-cpu-profiler --disable-heap-checker) (last release) on AMD
x86-64

2. On tcsh: setenv LD_PRELOAD /usr/lib/libtcmalloc.so 
3. Then emacs

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

Emacs should be able to run instead I've got this error:
src/tcmalloc.cc:351] Attempt to realloc invalid pointer: 0xfd64a0

Please provide any additional information below.
But however most of programs still available, I also got a Segmentation
fault in trying using ./configure and also nroff and stuff.

Hope this report could help you please let me know if you need to find
about more about this issue.

Thanks
Frederic

Original issue reported on code.google.com by fredericsmailbox on 18 Jun 2009 at 6:11

GoogleCodeExporter commented 9 years ago
This error means that code somewhere is trying to realloc memory that was 
allocated
before tcmalloc was loaded (and took over memory management responsibility). 
tcmalloc can't realloc code that was originally allocated by glibc.

I don't know how this could happen with LD_PRELOAD.  Maybe other libraries are 
being
loaded before tcmalloc?  Or maybe emacs is doing something dodgy with memory 
that
works on libc but not on tcmalloc.  It's hard to say.

You could try doing something like 'setenv LD_DEBUG=all', to see if that gives 
useful
information about library load ordering.

That said, we know that LD_PRELOAD is not 100% reliable, and we recommend folks 
don't
depend on it.  If you're up for it, you could try compiling emacs from source 
with
tcmalloc included that way, at least to see if that solves your problem.

Original comment by csilv...@gmail.com on 19 Jun 2009 at 3:18

GoogleCodeExporter commented 9 years ago

Original comment by csilv...@gmail.com on 21 Jun 2009 at 7:39

GoogleCodeExporter commented 9 years ago
It turns out emacs is really weird -- it does some process dumping and 
undumping when
it runs.  See, eg,
   http://git.savannah.gnu.org/cgit/emacs.git/tree/etc/DEBUG#n613
for how complicated it can be to get right.  Just using LD_PRELOAD on it won't 
work.

As for nroff, it's a shell script (at least on my system) and not a binary, so 
it's
not totally surprising that it would crash when used with LD_PRELOAD.  (The 
crash is
actually coming when trying to use bash with tcmalloc, which is likely to also 
be
complicated in a similar way to emacs, though I don't know the details.)

zsh seems to work ok under tcmalloc, so you can do
   env LD_PRELOAD=/home/csilvers/opensource/google-perftools/.libs/libtcmalloc.so zsh
/usr/bin/nroff

If you have other examples of binaries that you're having trouble with, feel 
free to
provide more details about them.  Otherwise, I'll close this bug.

Original comment by csilv...@gmail.com on 15 Oct 2009 at 12:40

GoogleCodeExporter commented 9 years ago
I'm closing the bug.  It may be possible to get emacs to use tcmalloc, but it 
would 
probably have to be compiled from scratch to do so (same with bash?), rather 
than 
using the LD_PRELOAD fix.  It might be possible to do some ugly hacks to get 
this to 
work, but it's probably not worth it.  So I'll close the bug WontFix.

Original comment by csilv...@gmail.com on 10 Mar 2010 at 6:10