Skip to content

Setting CPP_THREAD_SAFETY_TEST=1 causes a crash on 0.3.19 #3503

Closed
@arungiridhar

Description

@arungiridhar

With OpenBlas 0.3.19 on setting CPP_THREAD_SAFETY_TEST=1 there is a segfault when exiting from dgemv_tester, preventing the library from being built:

make -j 12 -C cpp_thread_test all
make[1]: Entering directory '/var/tmp/pamac-build-_/openblas-lapack/src/OpenBLAS-0.3.19/cpp_thread_test'
g++ -O2 -Wall -Wextra -Wshadow -fopenmp -std=c++11 dgemv_thread_safety.cpp ../libopenblas_zenp-r0.3.19.a -lm -lpthread -lgfortran -lm -lpthread -lgfortran -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../..  -lgfortran -lm -lgomp -lquadmath -lm -lpthread -lc   -o dgemv_tester
./dgemv_tester
*----------------------------*
| DGEMV thread safety tester |
*----------------------------*
Size of random matrices and vectors(N=M): 1024
Number of concurrent calls into OpenBLAS : 12
Number of testing rounds : 16
This test will need 96.1875 MiB of RAM

Initializing random number generator...done
Preparing to test CBLAS DGEMV thread safety
Allocating matrices...done
Allocating vectors...done
Filling matrices with random numbers...done
Filling vectors with random numbers...done
Testing CBLAS DGEMV thread safety
DGEMV round #0
Launching 12 threads simultaneously using OpenMP...done
Waiting for threads to finish...done
Comparing results from different threads...OK!

DGEMV round #1
Launching 12 threads simultaneously using OpenMP...done
Waiting for threads to finish...done
Comparing results from different threads...OK!

... (trimmed for brevity)

DGEMV round #15
Launching 12 threads simultaneously using OpenMP...done
Waiting for threads to finish...done
Comparing results from different threads...OK!

CBLAS DGEMV thread safety test PASSED!

make[1]: *** [Makefile:8: dgemv_tester] Segmentation fault (core dumped)
make[1]: *** Deleting file 'dgemv_tester'
make[1]: Leaving directory '/var/tmp/pamac-build-_/openblas-lapack/src/OpenBLAS-0.3.19/cpp_thread_test'
make: *** [Makefile:149: tests] Error 2
==> ERROR: A failure occurred in check().
    Aborting...

With the git source (commit ee823b6), there is no such crash in the threading tests:

make -j 12 -C cpp_thread_test all
make[1]: warning: -j12 forced in submake: resetting jobserver mode.
make[1]: Entering directory '/home/_/src/OpenBLAS/cpp_thread_test'
g++ -O2 -Wall -Wextra -Wshadow -fopenmp -std=c++11 dgemv_thread_safety.cpp ../libopenblas_zenp-r0.3.19.dev.a -lm -lpthread -lgfortran -lm -lpthread -lgfortran -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../..  -lgfortran -lm -lquadmath -lm -lc   -o dgemv_tester
./dgemv_tester
*----------------------------*
| DGEMV thread safety tester |
*----------------------------*
Size of random matrices and vectors(N=M): 1024
Number of concurrent calls into OpenBLAS : 12
Number of testing rounds : 16
This test will need 96.1875 MiB of RAM

Initializing random number generator...done
Preparing to test CBLAS DGEMV thread safety
Allocating matrices...done
Allocating vectors...done
Filling matrices with random numbers...done
Filling vectors with random numbers...done
Testing CBLAS DGEMV thread safety
DGEMV round #0
Launching 12 threads simultaneously using OpenMP...done
Waiting for threads to finish...done
Comparing results from different threads...OK!

DGEMV round #1
Launching 12 threads simultaneously using OpenMP...done
Waiting for threads to finish...done
Comparing results from different threads...OK!

... (trimmed for brevity)

DGEMV round #15
Launching 12 threads simultaneously using OpenMP...done
Waiting for threads to finish...done
Comparing results from different threads...OK!

CBLAS DGEMV thread safety test PASSED!

g++ -O2 -Wall -Wextra -Wshadow -fopenmp -std=c++11 dgemm_thread_safety.cpp ../libopenblas_zenp-r0.3.19.dev.a -lm -lpthread -lgfortran -lm -lpthread -lgfortran -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../..  -lgfortran -lm -lquadmath -lm -lc   -o dgemm_tester
./dgemm_tester
*----------------------------*
| DGEMM thread safety tester |
*----------------------------*
Size of random matrices(N=M=K): 1024
Number of concurrent calls into OpenBLAS : 12
Number of testing rounds : 16
This test will need 288 MiB of RAM

Initializing random number generator...done
Preparing to test CBLAS DGEMM thread safety
Allocating matrices...done
Filling matrices with random numbers...done
Testing CBLAS DGEMM thread safety
DGEMM round #0
Launching 12 threads simultaneously using OpenMP...done
Waiting for threads to finish...done
Comparing results from different threads...OK!

DGEMM round #1
Launching 12 threads simultaneously using OpenMP...done
Waiting for threads to finish...done
Comparing results from different threads...OK!

... (trimmed for brevity)

DGEMM round #15
Launching 12 threads simultaneously using OpenMP...done
Waiting for threads to finish...done
Comparing results from different threads...OK!

CBLAS DGEMM thread safety test PASSED!

make[1]: Leaving directory '/home/_/src/OpenBLAS/cpp_thread_test'
make[1]: warning: -j12 forced in submake: resetting jobserver mode.
make[1]: Entering directory '/home/_/src/OpenBLAS/exports'
perl ./gensymbol linktest  x86_64 _ 0 0 0 0 0 0 "" "" 1 0 1 1 1 1 > linktest.c
cc -O2 -DSMALL_MATRIX_OPT -DMAX_STACK_ALLOC=2048 -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=12 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.19.dev\" -msse3 -mssse3 -msse4.1 -mavx -mavx2 -mavx2 -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I..  -shared -o ../libopenblas_zenp-r0.3.19.dev.so \
-Wl,--whole-archive ../libopenblas_zenp-r0.3.19.dev.a -Wl,--no-whole-archive \
-Wl,-soname,libopenblas.so.0 -lm -lpthread -lgfortran -lm -lpthread -lgfortran
cc -O2 -DSMALL_MATRIX_OPT -DMAX_STACK_ALLOC=2048 -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=12 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.19.dev\" -msse3 -mssse3 -msse4.1 -mavx -mavx2 -mavx2 -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I..  -w -o linktest linktest.c ../libopenblas_zenp-r0.3.19.dev.so -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../..  -lgfortran -lm -lquadmath -lm -lc   && echo OK.
OK.
rm -f linktest
make[1]: Leaving directory '/home/_/src/OpenBLAS/exports'

 OpenBLAS build complete. (BLAS CBLAS LAPACK LAPACKE)

  OS               ... Linux             
  Architecture     ... x86_64               
  BINARY           ... 64bit                 
  C compiler       ... GCC  (cmd & version : cc (GCC) 11.1.0)
  Fortran compiler ... GFORTRAN  (cmd & version : GNU Fortran (GCC) 11.1.0)
  Library Name     ... libopenblas_zenp-r0.3.19.dev.a (Multi-threading; Max num-threads is 12)

0.3.19 was installed from the distro here: https://aur.archlinux.org/packages/openblas-lapack/

All build settings on both 0.3.19 and the git source were the same. Everything was left at default values except for setting CPP_THREAD_SAFETY_TEST=1.

This behavior causes a crash when exiting from GNU Octave as reported here: https://savannah.gnu.org/bugs/?61742

Hardware: AMD Ryzen 5 3600.
OS: Manjaro Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions