Sunday, April 17, 2011

» Workaround for Eclipse Helios JVM crashes

You might run into this too: when using Eclipse Helios (3.6.2 here), it sometimes crashes on an alleged double free in the JVM, detected by glibc.
That's actually a feature of glibc that serves to detect bugs and security issues, which kills a process that tries to free a previously allocated memory area that has already been freed.

In this case, however, it is most probably a false positive, but glibc still decides to kill the process.

The workaround is to run Eclipse with the environment variable MALLOC_CHECK_ set to 0. There are several ways to achieve this:

  1. when you run eclipse from a shell, run it like this:
    MALLOC_CHECK_=0 eclipse
  2. if you prefer to just run eclipse or by clicking on an icon, create the following file in your $HOME/bin, e.g. like this (just copy/paste into a shell):
    cat<<EOF >"$HOME/bin/eclipse"
    #!/bin/bash
    export MALLOC_CHECK_=0
    exec /usr/bin/eclipse "$@"
    EOF
    chmod 0755 "$HOME/bin/eclipse"
Note that with the latter option, you obviously need to adapt the fully qualified path to the eclipse script depending on how and where you installed it. If it comes from RPM packages, than /usr/bin/eclipse is fine. If, like me, you downloaded the tarball from eclipse.org and unpacked it somewhere under your home, you must change it accordingly -- e.g. to $HOME/apps/eclipse/eclipse

In any case, you should NOT add export MALLOC_CHECK_=0 to your ~/.profile or ~/.bashrc as that would turn off that glibc check for ALL the applications and processes you would run. And that's a bad idea.

Labels: , , ,

2 Comments:

Blogger redneck said...

This was very helpful even with eclipse 3.7 indigo, either on open- or sun-jdk.

19:37  
Blogger Scott said...

Thanks, that saved my eclipse.

04:43  

Post a Comment

Links to this post:

Create a Link

<< Home