Skip to content

JVM segfaults when calling JNILAPACK#dlange with null workspace #16

@jonathanschilling

Description

@jonathanschilling

Hi,

I just stumbled across an issue that popped up with JNILAPACK (which gets used by default on my machine).
A minimal non-working example is found here:
https://github.com/jonathanschilling/netlib_mnwe/blob/master/src/test/java/de/labathome/netlib_mnwe/NetlibMNWE.java

Essentially I want to call LAPACK's dlange with an empty workspace array, which is considered valid with the Fortran implementation.
Using JavaLAPACK and the old netlib-java by fommil, it is ok to pass null for the workspace array.
However, it seems to be required to pass new double[0] to NativeLAPACK in order to circumvent a segfault.

My guess is that it is always tried to resolve the workspace array in the JNI wrapper of the local native LAPACK,
which fails if the array is passed as null on the Java side.
My vague idea for a fix is to introduce an additional check in the JNI wrapper that maps a null array from the Java side to NULL passed to the native LAPACK method.

It would be great if you could fix this, since it would allow us to really use this library as a drop-in replacement for netlib-java.

Thanks in advance for your efforts in this case!
I am happy to provide more details on the problem and test potential fixes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions