[SunHELP] segmentation fault.....

Rakesh Kumar Bhatia Rakesh.Bhatia at synopsys.com
Fri Nov 6 15:08:56 CST 2009


Hi all,



I tried hard but failed to understand why I get segmentation fault error
program terminated by signal SEGV (no mapping at the fault address)

) program terminated by signal SEGV (no mapping at the fault address)

0xfecf41ce: _malloc_unlocked+0x014c:    andl     $0xfffffffd,0x00000008(%eax)

Current function is main (optimized)

  157   F77_FUNC ( pardiso ) (pt , &maxfct , &mnum , &mtype , &phase ,

(dbx) where

  [1] _malloc_unlocked(0x30, 0x32, 0x84407f8, 0x842fef8, 0x8047278,
0x806d239), at 0xfecf41ce

  [2] malloc(0x30, 0x8047230, 0x8440910, 0x806c9b1), at 0xfecf4058

  [3] pardiso_c_(0x80473c0, 0x804739c, 0x80473a0, 0x8047394, 0x80473b0,
0x8047390, 0x84406a0, 0x843fe60, 0x8440660, 0x0, 0x8047398, 0x80474c0,
0x80473a4, 0x8440710, 0x8440740, 0x80473a8, 0x80472f8, 0xfeffb104, 0x8406109,
0x8047358), at 0x806d239

  [4] pardiso_(0x80473c0, 0x804739c, 0x80473a0, 0x8047394, 0x80473b0,
0x8047390, 0x84406a0, 0x843fe60, 0x8440660, 0x0, 0x8047398, 0x80474c0,
0x80473a4, 0x8440710, 0x8440740, 0x80473a8), at 0x806c6eb

=>[5] main() (optimized), at 0x806bfae (line ~157) in "x86_pardiso_test.cc"

(dbx)



I am getting seg fault when I am doing symbolic factorization.



Any idea why I am getting this error? It would be more then appreciated



My test program is given below. I am using version 3.0 PARDISO libraries on
x86 Solaris to do symbolic factorization.



#include <stdio.h>

#include <stdlib.h>

#include <math.h>

/* Change this, if your Fortran compiler does not append underscores. */

/* e.g. the AIX compiler: #define F77_FUNC(func) func */



#ifdef AIX

#define F77_FUNC(func)  func

#else

#define F77_FUNC(func)  func ## _

#endif

extern "C"  int F77_FUNC(pardisoinit)

(void *, int *, int *);



extern "C" int F77_FUNC(pardiso)

              (void* handle,

               int * max_fac_store,

               int * matrix_number,

               int * matrix_type,

               int * ido,

               int * neqns,

               double* a,

               int * ia,

               int * ja,

               int * perm_user,

               int * nb,

               int * iparam,

               int * msglvl,

               double * b,

               double * x,

               int * error);







int main( void )

{

/* Matrix data. */



int n = 5;

int *ia;

int *ja;

double *a;

double *rhs;

double *x;



ia = (int *)calloc(sizeof(int), n + 1);

if(ia==NULL)

        exit(1);

ia[0]=1;

ia[1]=4;

ia[2]=6;

ia[3]=9;

ia[4]=12;

ia[5]=14;



/* Number of non zeros is in nnz*/

int nnz=13;



ja = (int *)calloc(sizeof(int), nnz);

if(ja==NULL)

        exit(1);

ja[0]=1;

ja[1]=2;

ja[2]=4;

ja[3]=1;

ja[4]=2;

ja[5]=3;

ja[6]=4;

ja[7]=5;

ja[8]=1;

ja[9]=3;

ja[10]=4;

ja[11]=2;

ja[12]=5;





a = (double *)calloc(sizeof(double), nnz);

if(a==NULL)

        exit(1);



a[0]= 1;

a[1]= -1;

a[2]= -3;

a[3]= -2;

a[4]= 5;

a[5]= 4;

a[6]= 6;

a[7]= 4;

a[8]= -4;

a[9]= 2;

a[10]= 7;

a[11]= 8;

a[12]= -5;



int mtype = 11; /* Real unsymmetric matrix */

/* RHS and solution vectors. */

/*double b[8], x[8];*/

 rhs = (double *)calloc(sizeof(double), n);

 x   = (double *)calloc(sizeof(double), n);

  if ((rhs == 0) || (x == 0))

        exit(1);





int nrhs = 1; /* Number of right hand sides. */



/* Internal solver memory pointer pt, */

/* 32-bit: int pt[64]; 64-bit: long int pt[64] */

/* or void *pt[64] should be OK on both architectures */

void *pt[64];

int ii;

/* pardiso_ control parameters. */

int iparm[64];

int maxfct, mnum, phase, error, msglvl;

/* Number of processors. */

int num_procs;

/* Auxiliary variables. */

char *var;

int i;

double ddum; /* Double dummy */

int idum; /* Integer dummy. */



/* -------------------------------------------------------------------- */

/* .. Setup pardiso_ control parameters. */

/* -------------------------------------------------------------------- */

maxfct = 1; /* Maximum number of numerical factorizations. */

mnum = 1; /* Which factorization to use. */

msglvl = 0; /* Print statistical information */

error = 0; /* Initialize error flag */

/* -------------------------------------------------------------------- */

/* .. Convert matrix from 0-based C-notation to Fortran 1-based */

/* notation. */

/* -------------------------------------------------------------------- */

/* .. Reordering and Symbolic Factorization. This step also allocates */

/* all memory that is necessary for the factorization. */

/* -------------------------------------------------------------------- */

for (ii=0; ii<64; ii++)

{

        pt[ii] = 0;

        iparm[ii]=0;

}

/* Numbers of processors, value of OMP_NUM_THREADS */

var = getenv("OMP_NUM_THREADS");

if(var != NULL)

sscanf( var, "%d", &num_procs );

else {

printf("Set environment OMP_NUM_THREADS to 1");

exit(1);



}

iparm[0]=1;

iparm[2] = num_procs;

phase = 11;

F77_FUNC ( pardiso ) (pt , &maxfct , &mnum , &mtype , &phase ,

&n, a, ia , ja , 0 , &nrhs ,

iparm , &msglvl , rhs , x , &error );

if (error != 0) {

printf("\nERROR during symbolic factorization: %d", error);

exit(1);

}



}



More information about the SunHELP mailing list