python-javabridge icon indicating copy to clipboard operation
python-javabridge copied to clipboard

javabridge.start_vm() Segmentation fault (core dumped)

Open alessandro-ferreira opened this issue 8 years ago • 9 comments

I'm using Ubuntu 16.04.1 LTS

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:        16.04
Codename:       xenial

When I try to use javabridge.start_vm() on python console I get Segmentation fault (core dumped).

$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import javabridge
>>> javabridge.start_vm()
Segmentation fault (core dumped)

I was getting this error using python-weka-wrapper:

$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import weka.core.jvm as jvm
>>> jvm.start()
DEBUG:weka.core.jvm:Adding bundled jars
DEBUG:weka.core.jvm:Classpath=['/usr/local/lib/python2.7/dist-packages/javabridge/jars/rhino-1.7R4.jar', '/usr/local/lib/python2.7/dist-packages/javabridge/jars/runnablequeue.jar', '/usr/local/lib/python2.7/dist-packages/javabridge/jars/cpython.jar', '/usr/local/lib/python2.7/dist-packages/weka/lib/weka.jar', '/usr/local/lib/python2.7/dist-packages/weka/lib/python-weka-wrapper.jar']
DEBUG:weka.core.jvm:MaxHeapSize=default
DEBUG:javabridge.jutil:Creating JVM object
DEBUG:javabridge.jutil:Signalling caller
Segmentation fault (core dumped)

but even just running this command alone in console I get the same error.

Javabridge VERSION 1.0.14

$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

alessandro-ferreira avatar Jun 26 '17 20:06 alessandro-ferreira

Hi Alessandro. There is no C stack trace of the segmentation fault, so it's difficult to tell what went wrong. As a simple first step, I would try uninstalling Javabridge and rebuilding it - these problems are often caused by an upgrade in Numpy or similar after Javabridge installation. If you can get a C stack trace, that would be helpful.

LeeKamentsky avatar Jun 27 '17 14:06 LeeKamentsky

I run the code with gdb

(gdb) run main.py
Starting program: /usr/bin/python main.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff0e58700 (LWP 9893)]
[New Thread 0x7fffee657700 (LWP 9894)]
[New Thread 0x7fffede56700 (LWP 9895)]
[New Thread 0x7fffcbca3700 (LWP 9896)]
[Thread 0x7fffede56700 (LWP 9895) exited]
[Thread 0x7fffee657700 (LWP 9894) exited]
[Thread 0x7ffff0e58700 (LWP 9893) exited]
DEBUG:weka.core.jvm:Adding bundled jars
DEBUG:weka.core.jvm:Classpath=['/usr/local/lib/python2.7/dist-packages/javabridge/jars/rhino-1.7R4.jar', '/usr/local/lib/python2.7/dist-packages/javabridge/jars/runnablequeue.jar', '/usr/local/lib/python2.7/dist-packages/javabridge/jars/cpython.jar', '/usr/local/lib/python2.7/dist-packages/weka/lib/weka.jar', '/usr/local/lib/python2.7/dist-packages/weka/lib/python-weka-wrapper.jar']
DEBUG:weka.core.jvm:MaxHeapSize=default
[New Thread 0x7fffede56700 (LWP 9899)]
DEBUG:javabridge.jutil:Creating JVM object

Thread 6 "python" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffede56700 (LWP 9899)]
0x00007fffa50002b4 in ?? ()
(gdb) backtrace
#0  0x00007fffa50002b4 in ?? ()
#1  0x0000000000000246 in ?? ()
#2  0x00007fffa5000160 in ?? ()
#3  0x00007fffbbde2c70 in VM_Operation::_names () from /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so
#4  0x00007fffede54ef0 in ?? ()
#5  0x00007fffbb9128cd in VM_Version::get_processor_features() () from /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Some additional info: I received the feedback about this crash yesterday from some users of my software. It seems that crash has affected recently another python-weka-wrapper devs: https://groups.google.com/forum/#!topic/python-weka-wrapper/NDcHSMk_Kyk

Numpy has realeased a new version this month: https://docs.scipy.org/doc/numpy-1.13.0/reference/

Thanks in advance

alessandro-ferreira avatar Jun 27 '17 16:06 alessandro-ferreira

I am able to run Javabridge with numpy 1.13 - I just created a clean Python 2.7 Anaconda environment on Ubuntu 16.04 with numpy 1.13, did a pip install of Javabridge and python-weka-wrapper. The following happens when I run your code above:

Python 2.7.13 | packaged by conda-forge | (default, May  2 2017, 12:48:11) 
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import weka.core.jvm as jvm
>>> jvm.start()
DEBUG:weka.core.jvm:Adding bundled jars
DEBUG:weka.core.jvm:Classpath=['/home/leek/anaconda2/envs/javabridge/lib/python2.7/site-pa ckages/javabridge/jars/rhino-1.7R4.jar', '/home/leek/anaconda2/envs/javabridge/lib/python2.7/site-packages/javabridge/jars/runnablequeue.jar', '/home/leek/anaconda2/envs/javabridge/lib/python2.7/site-packages/javabridge/jars/cpython.jar', '/home/leek/anaconda2/envs/javabridge/lib/python2.7/site-packages/weka/lib/python-weka-wrapper.jar', '/home/leek/anaconda2/envs/javabridge/lib/python2.7/site-packages/weka/lib/weka.jar']
DEBUG:weka.core.jvm:MaxHeapSize=default
DEBUG:javabridge.jutil:Creating JVM object
DEBUG:javabridge.jutil:Signalling caller
>>>

Can you send me the results from pip freeze?

Thanks, Lee

LeeKamentsky avatar Jun 27 '17 17:06 LeeKamentsky

$ pip freeze: https://pastebin.com/9MT4TSyR

In addiction, I have created a virtual env. I have forced to install numpy 1.12.0. But I still got the same error:

(tmp) $ pip install 'numpy==1.12.0'     
Collecting numpy==1.12.0
  Downloading numpy-1.12.0-cp27-cp27mu-manylinux1_x86_64.whl (16.5MB)
    100% |████████████████████████████████| 16.5MB 81kB/s 
Installing collected packages: numpy
Successfully installed numpy-1.12.0
(tmp) $ pip install javabridge
Collecting javabridge
  Downloading javabridge-1.0.14.tar.gz (1.3MB)
    100% |████████████████████████████████| 1.3MB 357kB/s 
Requirement already satisfied: numpy in ./lib/python2.7/site-packages (from javabridge)
Building wheels for collected packages: javabridge
  Running setup.py bdist_wheel for javabridge ... done
 Successfully built javabridge
Installing collected packages: javabridge
Successfully installed javabridge-1.0.14
(tmp) $ pip install python-weka-wrapper
Collecting python-weka-wrapper
  Downloading python-weka-wrapper-0.3.10.tar.gz (90kB)
    100% |████████████████████████████████| 92kB 209kB/s 
Requirement already satisfied: javabridge>=1.0.14 in ./lib/python2.7/site-packages (from python-weka-wrapper)
Requirement already satisfied: numpy in ./lib/python2.7/site-packages (from python-weka-wrapper)
Building wheels for collected packages: python-weka-wrapper
  Running setup.py bdist_wheel for python-weka-wrapper ... done
  Successfully built python-weka-wrapper
Installing collected packages: python-weka-wrapper
Successfully installed python-weka-wrapper-0.3.10
(tmp) $ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import weka.core.jvm as jvm
>>> jvm.start()
DEBUG:weka.core.jvm:Adding bundled jars
DEBUG:weka.core.jvm:Classpath=['/tmp/tmp/lib/python2.7/site-packages/javabridge/jars/rhino-1.7R4.jar', '/tmp/tmp/lib/python2.7/site-packages/javabridge/jars/runnablequeue.jar', '/tmp/tmp/lib/python2.7/site-packages/javabridge/jars/cpython.jar', '/tmp/tmp/local/lib/python2.7/site-packages/weka/lib/weka.jar', '/tmp/tmp/local/lib/python2.7/site-packages/weka/lib/python-weka-wrapper.jar']
DEBUG:weka.core.jvm:MaxHeapSize=default
DEBUG:javabridge.jutil:Creating JVM object
DEBUG:javabridge.jutil:Signalling caller
Segmentation fault (core dumped)
(tmp) $ pip freeze
javabridge==1.0.14
numpy==1.12.0
python-weka-wrapper==0.3.10

Maybe the problem may actually be related to some lib java.

Thanks again, Alessandro

alessandro-ferreira avatar Jun 27 '17 18:06 alessandro-ferreira

I noticed that you don't seem to have Cython installed. Javabridge needs that installed prior to pip install javabridge. Can you start fresh and do a pip install Cython before installing Javabridge. For me:

$ pip freeze
certifi==2017.4.17
Cython==0.25.2
javabridge==1.0.14
numpy==1.13.0
python-weka-wrapper==0.3.10
six==1.10.0

If it is a problem with the Java libraries and you solve it, I'd appreciate it if you'd post the answer here and close. Thanks for being persistent. --Lee

LeeKamentsky avatar Jun 27 '17 18:06 LeeKamentsky

I have installed Cython but the problem persists.

I uninstalled java-oracle and installed OpenJDK. But at this point it's all messed up in my machine, it seems to be trying to install javabridge in virtual env with the old configs:

EDIT: JAVA_HOME was not update. I export new JAVA_HOME and javabridged installed. However, in this case i got the same error.

$ source bin/activate
$ pip freeze
Cython==0.25.2
javabridge==1.0.14
numpy==1.13.0
$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import javabridge
>>> javabridge.start_vm()
Segmentation fault (core dumped)

Anyway I managed to install javabridge and python-weka-wrapper without any problem on another Ubuntu 16.04, numpy 1.13.0 and openjdk version "1.8.0_131".

It should be some problem related to some recent update and some machines, since the same problem was reported by two different users yesterday in python-weka-wrapper group, but works fine in others.

I'll update if I can find out anything new.

alessandro-ferreira avatar Jun 27 '17 20:06 alessandro-ferreira

Commenting to add in numbers. Same issue. Worked with numpy 1.11.3 and java version "1.8.0_131" on a Ubuntu 16.04.2. Gives a Segmentation fault with numpy 1.13, java version "1.8.0_131", Ubuntu 16.04.2.

rupsaijna avatar Jun 28 '17 04:06 rupsaijna

Does the problem still persist with numpy 1.13.1? I tried replicating the problem last week on a fresh Ubuntu 16.0.4.2 installation (initial and fully updated), using OpenJDK 1.8.0_131 and javabridge 1.0.14, but couldn't replicate the segfault (Python 2.7 and 3.5). In each case, I used virtualenv with no site packages and only the absolute minimum of required packages (Cython wasn't required, as I had the Python headers installed):

Cython==0.25.2
javabridge=1.0.14
numpy==1.13.0
pkg-resources==0.0.0
python-weka-wrapper(3)==<latest>

fracpete avatar Jul 09 '17 21:07 fracpete

Yes, I coud reinstall everything fine in another computer with fresh Ubuntu 16.0.4.2, but not in the one where the bug appeared. Not even with virtualenv and python 3.5, nor uninstalling and reinstalling both java, javabridge and the wrapper.

On Sun, Jul 9, 2017 at 4:40 PM, Peter Reutemann [email protected] wrote:

Does the problem still persist with numpy 1.13.1? I tried replicating the problem last week on a fresh Ubuntu 16.0.4.2 installation (initial and fully updated), using OpenJDK 1.8.0_131 and javabridge 1.0.14, but couldn't replicate the segfault (Python 2.7 and 3.5). In each case, I used virtualenv with no site packages and only the absolute minimum of required packages (Cython wasn't required, as I had the Python headers installed):

Cython==0.25.2 javabridge=1.0.14 numpy==1.13.0 pkg-resources==0.0.0 python-weka-wrapper(3)==

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LeeKamentsky/python-javabridge/issues/114#issuecomment-313966025, or mute the thread https://github.com/notifications/unsubscribe-auth/ANsF6AhEmw5al1rskFecqqBhYF12xWl1ks5sMUjJgaJpZM4OF1wC .

-- Alán Fernando Muñoz González *Licenciatura en Ciencias Genómicas * UNAM, Campus Morelos Generación 12

afermg avatar Jul 10 '17 00:07 afermg