SegFault when using jnius with numpy
See original GitHub issueThis ticket is similar to https://github.com/numpy/numpy/issues/15691 As I am not sure where the issue exactly is - jnius or numpy? Using jnius+numpy causes issues in CentOS7 when python is installed with anaconda.
Reproducing code example:
I can reproduce this exactly with:
$ docker run --rm -it centos:7 /bin/bash
# yum install -y wget bzip2 which java-1.8.0-openjdk-devel
# wget https://repo.anaconda.com/miniconda/Miniconda3-4.7.12-Linux-x86_64.sh
# bash ./Miniconda3-4.7.12-Linux-x86_64.sh -b
# /root/miniconda3/bin/pip install pyjnius==1.2.1 numpy==1.17.4
# /root/miniconda3/bin/python
>>> import jnius
>>> import numpy as np
>>> tmp = np.linalg.inv(np.random.rand(24, 24))
Segmentation fault
Error message:
GDB Traceback for the SegFault:
(gdb) r
Starting program: /root/miniconda3/bin/python run.py
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Detaching after fork from child process 533.
Detaching after fork from child process 535.
Detaching after fork from child process 536.
Program received signal SIGSEGV, Segmentation fault.
0x00007f3026ee82b4 in ?? ()
Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7_6.3.x86_64 java-1.8.0-openjdk-headless-1.8.0.242.b08-0.el7_7.x86_64
(gdb) bt
#0 0x00007f3026ee82b4 in ?? ()
#1 0x0000000000000246 in ?? ()
#2 0x00007f3026ee8160 in ?? ()
#3 0x00007f303829a6f8 in Abstract_VM_Version::_reserve_for_allocation_prefetch ()
from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/lib/amd64/server/libjvm.so
#4 0x00007fff1187df20 in ?? ()
#5 0x00007f3037d804dd in VM_Version::get_processor_features() ()
from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/lib/amd64/server/libjvm.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)
Numpy/Python version information:
- Numpy - 1.17.4
- Jnius - 1.2.1
- Python - 3.7.4 / Anaconda 4.7.12
- GCC - 7.3.0
- Linux x86-64 - CentOS 7
Note: It is reproducible on
- Anaconda 4.5.4 / Python 3.6.5 / GCC 7.2.0
- CentOS7’s yum python3 package (3.6.8) / GCC 4.8.5
It is not reproducible on MacOS.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
BUG: SegFault when using numpy with jnius · Issue #15691
I had a nasty SegFault issue with numpy+jnius in my program. And after much debugging I found that for some reason -> it...
Read more >Numpy as_strided() segmentation fault - python - Stack Overflow
My way to do that was to read array and use as_strided(), then copy values to new array. It works for images in...
Read more >numpy results in segmentation fault - Google Groups
Hi , I was trying to solve the hackerrank and was using python 3.7.x. ... the code is crashing ? Does anyone have...
Read more >Segfault from root when using python threading of numpy ...
I am using a code that makes almost no use of root, a part from using some numpy arrays produced with AsNumpy in...
Read more >NumPy 1.8.1 Release Notes — NumPy v1.25.dev0 Manual
gh-4051: fix uninitialized use in _strided_to_strided_string_to_datetime. gh-4093: Loading compressed .npz file fails under Python 2.6.6. gh-4138: segfault ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just to note that in https://github.com/numpy/numpy/issues/15691 we tracked it down to be probably related to threading. I.e. setting
OMP_NUM_THREADS=1
which disables the threading in openblas (or MKL if that is used here) makes things pass. It would be nice to know whether this is more likely an issue with jnius, an issue with OpenBLAS, or a general clash without an easy solution.built from source
from wheel: