question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SegFault when using jnius with numpy

See original GitHub issue

This 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:open
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sebergcommented, Mar 3, 2020

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.

0reactions
tshirtmancommented, Apr 25, 2020

built from source

>>> numpy.show_config()
blas_mkl_info:
  NOT AVAILABLE
blis_info:
  NOT AVAILABLE
openblas_info:
  NOT AVAILABLE
atlas_3_10_blas_threads_info:
  NOT AVAILABLE
atlas_3_10_blas_info:
  NOT AVAILABLE
atlas_blas_threads_info:
  NOT AVAILABLE
atlas_blas_info:
  NOT AVAILABLE
accelerate_info:
  NOT AVAILABLE
blas_info:
    libraries = ['blas', 'blas']
    library_dirs = ['/usr/lib/x86_64-linux-gnu']
    include_dirs = ['/usr/local/include', '/usr/include', '/home/gabriel/.virtualenvs/jnius37/include']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    libraries = ['blas', 'blas']
    library_dirs = ['/usr/lib/x86_64-linux-gnu']
    include_dirs = ['/usr/local/include', '/usr/include', '/home/gabriel/.virtualenvs/jnius37/include']
    language = c
lapack_mkl_info:
  NOT AVAILABLE
openblas_lapack_info:
  NOT AVAILABLE
openblas_clapack_info:
  NOT AVAILABLE
flame_info:
  NOT AVAILABLE
atlas_3_10_threads_info:
  NOT AVAILABLE
atlas_3_10_info:
  NOT AVAILABLE
atlas_threads_info:
  NOT AVAILABLE
atlas_info:
  NOT AVAILABLE
lapack_info:
    libraries = ['lapack', 'lapack']
    library_dirs = ['/usr/lib/x86_64-linux-gnu']
    language = f77
lapack_opt_info:
    libraries = ['lapack', 'lapack', 'blas', 'blas']
    library_dirs = ['/usr/lib/x86_64-linux-gnu']
    language = c
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    include_dirs = ['/usr/local/include', '/usr/include', '/home/gabriel/.virtualenvs/jnius37/include']

from wheel:

>>> numpy.show_config()
blas_mkl_info:
  NOT AVAILABLE
blis_info:
  NOT AVAILABLE
openblas_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
lapack_mkl_info:
  NOT AVAILABLE
openblas_lapack_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
lapack_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found