The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

zgesdd memory corruption

Post here if you want to report a bug to the LAPACK team

zgesdd memory corruption

Postby fkluknav » Thu Apr 09, 2015 10:14 am

Hi,

a simple (hopefully correct) reproducer that causes zgesdd to segfault:

#include <stdlib.h>

typedef struct {double r,i;} complex_double;
typedef int fint;
extern void zgesdd_(char*,int*,int*,complex_double*,int*,double*,complex_double*,int*,complex_double*,int*,complex_double*,int*,double*,int*,int*);

int main()
{
int i;
fint m=3;
fint n=4;
fint minmn=m<n?m:n;
fint lwork=57; //scipy uses 57, should be >= 2*min(M,N)+max(M,N)
fint lrwork = 5*minmn;
fint liwork = 8*minmn;
fint info = 0;
fint unused = 1;

complex_double *a=malloc(n*m*sizeof(complex_double));
double *s=malloc(minmn*sizeof(double));
complex_double *work=malloc(lwork*sizeof(complex_double));
double *rwork=malloc(lrwork*sizeof(double));
fint *iwork=malloc(liwork*sizeof(int));

for (i=0; i<m*n; ++i) {
a[i].r=0;
a[i].i=(double)rand()/rand();
}

zgesdd_("N", &m , &n , a , &m, s, NULL, &unused, NULL, &unused, work, &lwork, rwork, iwork, &info);

free(a);
free(s);
free(work);
free(rwork);
free(iwork);

return 0;
}
fkluknav
 
Posts: 3
Joined: Tue Feb 04, 2014 10:42 am

Return to Bug report

Who is online

Users browsing this forum: No registered users and 1 guest