help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] gsl_spline_alloc: malloc(): memory corruption


From: Francesco Montesano
Subject: [Help-gsl] gsl_spline_alloc: malloc(): memory corruption
Date: Tue, 3 Aug 2010 18:18:27 +0200

Dear GSLers,

I have a memory problem when allocating the gsl spline. I get the same error
when running the code on my machine (a brend new quadcore, 8GB ram machine
with kubuntu 10.04, with problably one of the last version of gsl installed)
and on the computer cluster I use (I've installed gsl myself localy more
than one year ago and used without problems (also the spline)). On the
cluster I have the "totalview" debugger that gives the same error and seems
to identify it at the beginning of the function
"gsl_spline *gsl_spline_alloc (const gsl_interp_type * T, size_t size)"
when
"gsl_spline * spline = (gsl_spline *) malloc (sizeof(gsl_spline));"

In the following I give a sample of the code and the error message I get.
Can anyone help me or suggest a solution?

thanks in advance

Francesco

Here is an idea of the structure of my code (called mcmc.cpp):

#include <gsl/gsl_spline.h>
>
> /* Other common variables */
> gsl_spline *spllin;   //gsl spline of the linear ps
> gsl_interp_accel *acclin;
>
> int th2spline(string thfile, gsl_spline *spl, gsl_interp_accel *acc);
>
> int main()
> {
>   /* other variable declarations */
>   string filename = "file.dat";    //contains about 750 lines
>
>   /* Here I read 4 files and convert their content to gsl vectors an
> matrices (their sizes are alway less then 1000 per dimension and I
> deallocate all that I don't need after the various operations)  */
>
>   dimlin = th2spline(filename, spllin, acclin);


>    /* do calculations */
>
>    gsl_spline_free(&spllin);
>    gsl_interp_accel_free(acclin);
>
}
>
>
>
> /*==========================================================================*/
> /* read the file and store it in the gsl_spline and gsl_interp_accel
>                                                   */
>
> /*==========================================================================*/
> int th2spline(string thfile, gsl_spline *spl, gsl_interp_accel *acc)
> {
>   size_t i;   //loop integers
>   size_t dimth;   //dimention of the theory power spectrum
>   vector<in_data> temp;   //temporary vector to read the file
>   double *k, *pk;    //array containing the theory power spectrum
>
>   dimth = size_t(input_data(thfile, temp, 0));  //read the file "thfile"
> and fill the vector "temp" and return the size of "temp"
>
>   k = new double(dimth);    //allocate the arrays for the theoy power
> spectrum
>   pk = new double(dimth);
>
>   for(i=0; i<dimth; ++i){   //convert vector to array
>     k[i] = temp[i].x;
>     pk[i] = temp[i].y;
>   }
>   temp.clear();   //clear the vector
>
>   spl = gsl_spline_alloc(gsl_interp_linear, dimth);
>   acc = gsl_interp_accel_alloc();
>   if(gsl_spline_init(spl, k, pk, dimth) != 0){
>     cerr << "Problem initialing the the " << gsl_spline_name(spl) << " for
> the file " << thfile << endl;
>     exit(19);
>   }
>
>   delete[] k;   //deallocate the arrays
>   delete[] pk;
>   return dimth;
> }
>


This is the error I get

> *** glibc detected *** ./mcmc: malloc(): memory corruption:
> 0x00000000025724b0 ***
> ======= Backtrace: =========
> /lib/libc.so.6(+0x775b6)[0x7f6c63ed05b6]
> /lib/libc.so.6(+0x7b6d8)[0x7f6c63ed46d8]
> /lib/libc.so.6(__libc_malloc+0x6e)[0x7f6c63ed558e]
> /usr/lib/libgsl.so.0(gsl_spline_alloc+0x23)[0x7f6c64c64593]
> ./mcmc[0x404f23]
> ./mcmc[0x403471]
> /lib/libc.so.6(__libc_start_main+0xfd)[0x7f6c63e77c4d]
> ./mcmc[0x402849]
> ======= Memory map: ========
> 00400000-00409000 r-xp 00000000 08:11 17253415
> /data01/montefra/SDSSDR7/Codes/mcmc
> 00608000-00609000 r--p 00008000 08:11 17253415
> /data01/montefra/SDSSDR7/Codes/mcmc
> 00609000-0060a000 rw-p 00009000 08:11 17253415
> /data01/montefra/SDSSDR7/Codes/mcmc
> 02571000-025c3000 rw-p 00000000 00:00 0
> [heap]
> 7f6c5c000000-7f6c5c021000 rw-p 00000000 00:00 0
> 7f6c5c021000-7f6c60000000 ---p 00000000 00:00 0
> 7f6c633d6000-7f6c639d7000 rw-p 00000000 00:00 0
> 7f6c63e59000-7f6c63fd3000 r-xp 00000000 08:01 171895
> /lib/libc-2.11.1.so
> 7f6c63fd3000-7f6c641d2000 ---p 0017a000 08:01 171895
> /lib/libc-2.11.1.so
> 7f6c641d2000-7f6c641d6000 r--p 00179000 08:01 171895
> /lib/libc-2.11.1.so
> 7f6c641d6000-7f6c641d7000 rw-p 0017d000 08:01 171895
> /lib/libc-2.11.1.so
>
> 7f6c641d7000-7f6c641dc000 rw-p 00000000 00:00
> 0
>
> 7f6c641dc000-7f6c641f2000 r-xp 00000000 08:01 171783
> /lib/libgcc_s.so.1
>
> 7f6c641f2000-7f6c643f1000 ---p 00016000 08:01 171783
> /lib/libgcc_s.so.1
>
> 7f6c643f1000-7f6c643f2000 r--p 00015000 08:01 171783
> /lib/libgcc_s.so.1
>
> 7f6c643f2000-7f6c643f3000 rw-p 00016000 08:01 171783
> /lib/libgcc_s.so.1
>
> 7f6c643f3000-7f6c64475000 r-xp 00000000 08:01 172077
> /lib/libm-2.11.1.so
>
> 7f6c64475000-7f6c64674000 ---p 00082000 08:01 172077
> /lib/libm-2.11.1.so
>
> 7f6c64674000-7f6c64675000 r--p 00081000 08:01 172077
> /lib/libm-2.11.1.so
>
> 7f6c64675000-7f6c64676000 rw-p 00082000 08:01 172077
> /lib/libm-2.11.1.so
>
> 7f6c64676000-7f6c6476c000 r-xp 00000000 08:01 670522
> /usr/lib/libstdc++.so.6.0.13
>
> 7f6c6476c000-7f6c6496c000 ---p 000f6000 08:01 670522
> /usr/lib/libstdc++.so.6.0.13
>
> 7f6c6496c000-7f6c64973000 r--p 000f6000 08:01 670522
> /usr/lib/libstdc++.so.6.0.13
>
> 7f6c64973000-7f6c64975000 rw-p 000fd000 08:01 670522
> /usr/lib/libstdc++.so.6.0.13
>
> 7f6c64975000-7f6c6498a000 rw-p 00000000 00:00
> 0
>
> 7f6c6498a000-7f6c649c3000 r-xp 00000000 08:01 673119
> /usr/lib/libgslcblas.so.0.0.0
>
> 7f6c649c3000-7f6c64bc2000 ---p 00039000 08:01 673119
> /usr/lib/libgslcblas.so.0.0.0
>
> 7f6c64bc2000-7f6c64bc3000 r--p 00038000 08:01 673119
> /usr/lib/libgslcblas.so.0.0.0
>
> 7f6c64bc3000-7f6c64bc4000 rw-p 00039000 08:01 673119
> /usr/lib/libgslcblas.so.0.0.0
>
> 7f6c64bc4000-7f6c64dc0000 r-xp 00000000 08:01 673118
> /usr/lib/libgsl.so.0.14.0
>
> 7f6c64dc0000-7f6c64fbf000 ---p 001fc000 08:01 673118
> /usr/lib/libgsl.so.0.14.0
>
> 7f6c64fbf000-7f6c64fc2000 r--p 001fb000 08:01 673118
> /usr/lib/libgsl.so.0.14.0
>
> 7f6c64fc2000-7f6c64fcb000 rw-p 001fe000 08:01 673118
> /usr/lib/libgsl.so.0.14.0
>
> 7f6c64fcb000-7f6c64feb000 r-xp 00000000 08:01 171880
> /lib/ld-2.11.1.so
>
> 7f6c651be000-7f6c651c3000 rw-p 00000000 00:00
> 0
>
> 7f6c651e8000-7f6c651eb000 rw-p 00000000 00:00
> 0
>
> 7f6c651eb000-7f6c651ec000 r--p 00020000 08:01 171880
> /lib/ld-2.11.1.so
>
> 7f6c651ec000-7f6c651ed000 rw-p 00021000 08:01 171880
> /lib/ld-2.11.1.so
>
> 7f6c651ed000-7f6c651ee000 rw-p 00000000 00:00
> 0
>
> 7fff41f70000-7fff41f85000 rw-p 00000000 00:00 0
> [stack]
>
> 7fff41fff000-7fff42000000 r-xp 00000000 00:00 0
> [vdso]
>
> ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
> [vsyscall]
>

-- 
personals: address@hidden, address@hidden (messenger),
address@hidden
work: address@hidden

http://picasaweb.google.it/franz.bergesund


reply via email to

[Prev in Thread] Current Thread [Next in Thread]