SciRuby / rb-gsl

Ruby interface to the GNU Scientific Library
https://github.com/SciRuby/rb-gsl
Other
100 stars 46 forks source link

GSL::Blas.zgemm crashes #45

Open daxtens opened 7 years ago

daxtens commented 7 years ago

Any attempt to run GSL::Blas.zgemm causes a crash:

2.2.6 :001 > require 'gsl'
 => true 
2.2.6 :002 > GSL::Blas.zgemm
irb):2: [BUG] Segmentation fault at 0x00000000000000
ruby 2.2.6p396 (2016-11-15 revision 56800) [powerpc64le-linux]

-- Control frame information -----------------------------------------------
c:0019 p:---- s:0075 e:000074 CFUNC  :zgemm
c:0018 p:0013 s:0072 e:000071 EVAL   (irb):2 [FINISH]
<snip>

This is a NULL pointer dereference in rb_gsl_blas_zgemm in blas3.c:

In line 94, you have:

  gsl_complex *pa = NULL, *pb = NULL;

Then line 97 tries to dereference pa and assign something to a member:

  (*pa).dat[0] = 1.0; (*pa).dat[1] = 0.0;

This causes the null pointer dereference.

I found this with cppcheck.