mpimd-csc / flexiblas

FlexiBLAS - A BLAS and LAPACK wrapper library with runtime exchangeable backends. This is only a mirror of https://gitlab.mpi-magdeburg.mpg.de/software/flexiblas-release
https://www.mpi-magdeburg.mpg.de/projects/flexiblas
GNU Lesser General Public License v3.0
37 stars 7 forks source link

octave-statistics segfaults with flexiblas/openblaso #5

Closed Enchufa2 closed 3 years ago

Enchufa2 commented 4 years ago

Reported here. It looks like with flexiblas enabled octave, octave-statistics now has a segfault in one of its tests:

https://koschei.fedoraproject.org/package/octave-statistics?collection=f34

   canoncorr.m .................................................
RPM build errors:
/var/tmp/rpm-tmp.PZIGXq: line 33: 915255 Segmentation fault      (core dumped)

The trace reported (same with openblas-serial succeeds):

FLEXIBLAS=/lib64/libopenblaso.so octave -H -q --no-window-system --no-site-file --eval 'pkg("local_list",fullfile("/home/orion/rpmbuild/BUILDROOT/octave-statistics-1.4.1-6.fc34.x86_64/usr/share/octave","octave_packages"));pkg("load","statistics");test("/home/orion/rpmbuild/BUILDROOT/octave-statistics-1.4.1-6.fc34.x86_64/usr/share/octave/packages/statistics-1.4.1/canoncorr.m");'
OpenJDK 64-Bit Server VM warning: Archived non-system classes are disabled because the java.system.class.loader property is specified (value = "org.octave.OctClassLoader"). To use archived non-system classes, this property must be not be set
Segmentation fault (core dumped)

Thread 1 "octave-cli-5.2." received signal SIGSEGV, Segmentation fault.
0x00007ffff0f1eb19 in dsyrk_thread_UT (args=0x7fffffff8db0, range_m=0x0, range_n=0x0, sa=0x7fffb4d31000, sb=0x7fffb4e31000, mypos=0) at level3_syrk_threaded.c:508
508     int CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa, FLOAT *sb, BLASLONG mypos){
(gdb) bt
#0  0x00007ffff0f1eb19 in dsyrk_thread_UT (args=0x7fffffff8db0, range_m=0x0, range_n=0x0, sa=0x7fffb4d31000, sb=0x7fffb4e31000, mypos=0) at level3_syrk_threaded.c:508
#1  0x00007ffff0e2152f in dsyrk_ (UPLO=<optimized out>, TRANS=<optimized out>, N=<optimized out>, K=<optimized out>, alpha=<optimized out>, a=<optimized out>, ldA=0x7fffffff8ef0, beta=0x7fffffff8f20, c=0x555555f1faa0,
     ldC=0x7fffffff8ed8) at syrk.c:370
#2  0x00007ffff67ac436 in _Z5xgemmRK6MatrixS1_15blas_trans_typeS2_ (a=..., b=..., transa=blas_trans, transb=blas_no_trans) at liboctave/array/Array.h:582
#3  0x00007ffff75336ee in oct_binop_trans_mul (a1=..., a2=...) at libinterp/octave-value/ov-re-mat.cc:145
#4  0x00007ffff781ab44 in do_binary_op (ti=..., op=octave_value::op_herm_mul, v1=..., v2=...) at libinterp/octave-value/ov.cc:2407

(gdb) list
503     #endif
504
505       return 0;
506     }
507
508     int CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa, FLOAT *sb, BLASLONG mypos){
509
510       blas_arg_t newarg;
511
512     #ifndef USE_ALLOC_HEAP
(gdb) up
#1  0x00007ffff0e2152f in dsyrk_ (UPLO=<optimized out>, TRANS=<optimized out>, N=<optimized out>, K=<optimized out>, alpha=<optimized out>, a=<optimized out>, ldA=0x7fffffff8ef0, beta=0x7fffffff8f20, c=0x555555f1faa0,
     ldC=0x7fffffff8ed8) at syrk.c:370
370         (syrk[4 | (uplo << 1) | trans ])(&args, NULL, NULL, sa, sb, 0);
(gdb) up
#2  0x00007ffff67ac436 in _Z5xgemmRK6MatrixS1_15blas_trans_typeS2_ (a=..., b=..., transa=blas_trans, transb=blas_no_trans) at liboctave/array/Array.h:582
582       const T * data (void) const { return slice_data; }
(gdb) print a
$1 = (const class Matrix &) @0x7fffffff9020: {<NDArray> = {<MArray<double>> = {<Array<double>> = {_vptr.Array = 0x7ffff7f95750 <vtable for Matrix+16>, dimensions = {rep = 0x555555f04180}, rep = 0x555555f45dc0,
         slice_data = 0x555555f07200, slice_len = 20}, <No data fields>}, <No data fields>}, <No data fields>}
(gdb) print b
$2 = (const class Matrix &) @0x7fffffff8ff0: {<NDArray> = {<MArray<double>> = {<Array<double>> = {_vptr.Array = 0x7ffff7f95750 <vtable for Matrix+16>, dimensions = {rep = 0x555555f04180}, rep = 0x555555f45dc0,
         slice_data = 0x555555f07200, slice_len = 20}, <No data fields>}, <No data fields>}, <No data fields>}

Reporting here because we don't know whether this is flexiblas' or openblas' fault. If the latter, we may need to change the system-wide default. Please, let me know if you need anything else.

Enchufa2 commented 3 years ago

Did you have a chance to look at this? Any idea whether this is due to FlexiBLAS, OpenBLAS or Octave?

Enchufa2 commented 3 years ago

A quick way to test this:

$ docker run --rm -it fedora:rawhide
$ dnf install -y octave-statistics flexiblas-*
$ CMD='octave -H -q --no-window-system --no-site-file --eval pkg("load","statistics");test("/usr/share/octave/packages/statistics-1.4.1/canoncorr.m");'
$ FLEXIBLAS=openblas-serial $CMD
PASSES 7 out of 7 tests
$ FLEXIBLAS=openblas-openmp $CMD
Segmentation fault (core dumped)
$ FLEXIBLAS=openblas-threads $CMD
Segmentation fault (core dumped)

but

$ FLEXIBLAS=blis-serial $CMD
PASSES 7 out of 7 tests
$ FLEXIBLAS=blis-openmp $CMD
PASSES 7 out of 7 tests
$ FLEXIBLAS=blis-threads $CMD
PASSES 7 out of 7 tests
Enchufa2 commented 3 years ago

A simpler test:

LD_PRELOAD=/usr/lib64/libopenblas.so $CMD
PASSES 7 out of 7 tests
LD_PRELOAD=/usr/lib64/libopenblaso.so $CMD
Segmentation fault (core dumped)

This bypasses FlexiBLAS completely, so it can't be a bug in FlexiBLAS.