LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   runtime error ( double free or corruption (out)) mid way through reading in file (http://www.linuxquestions.org/questions/programming-9/runtime-error-double-free-or-corruption-out-mid-way-through-reading-in-file-792656/)

quantum_leaf 03-02-2010 10:59 AM

runtime error ( double free or corruption (out)) mid way through reading in file
 
Hi,

I writing a function that reads in data from a file into a 2dfloat array.

the loop:
ifstream inf;
inf.open(filename);
inf>>numTimeSteps>>numViews;

for(int i=0;i<1;i++){
for(int j=0;j<420;j++){
inf>>info[i][j];
cout<<"ij "<<i<<" "<<j<<" inf"<<info[i][j]<<endl;
}

}

run fine up to i=0, j=417

and then crashes on 418. The backtrace begins:


*** glibc detected *** ./build/viewSelector: double free or corruption (out): 0x0000000001b6ac30 ***
======= Backtrace: =========
/lib/libc.so.6[0x7fd40c26ccb8]
/lib/libc.so.6(cfree+0x76)[0x7fd40c26f276]
/usr/lib/libstdc++.so.6(_ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE6do_getES3_S3_RSt8ios_ba seRSt12_Ios_IostateRf+0x14a)[0x7fd40ca9447a]
/usr/lib/libstdc++.so.6(_ZNSi10_M_extractIfEERSiRT_+0x91)[0x7fd40ca7ff51]
./build/viewSelector(_ZN9infoSheet8loadInfoEPc+0x16f)[0x6332cb]
./build/viewSelector(_ZN12ViewSelectorC1Ev+0x1a7)[0x62c067]
./build/viewSelector(main+0x22)[0x62c0bb]
/lib/libc.so.6(__libc_start_main+0xe6)[0x7fd40c2135a6]
./build/viewSelector[0x62bc19]
======= Memory map: ========
00400000-00d59000 r-xp 00000000 09:01 7815172 /home/zoizoi/sunLoom/psyforge/VAS/build/viewSelector
00f59000-00f5a000 r--p 00959000 09:01 7815172 /home/zoizoi/sunLoom/psyforge/VAS/build/viewSelector
00f5a000-00f67000 rw-p 0095a000 09:01 7815172 /home/zoizoi/sunLoom/psyforge/VAS/build/viewSelector
00f67000-00f6d000 rw-p 00f67000 00:00 0
01b57000-01b78000 rw-p 01b57000 00:00 0 [heap]
410a8000-410aa000 rwxp 00000000 00:0f 750 /dev/zero
7fd404000000-7fd404021000 rw-p 7fd404000000 00:00 0
7fd404021000-7fd408000000 ---p 7fd404021000 00:00 0
7fd40a5a2000-7fd40a5a7000 r-xp 00000000 09:00 16108 /usr/lib/libXdmcp.so.6.0.0
7fd40a5a7000-7fd40a7a6000 ---p 00005000 09:00 16108 /usr/lib/libXdmcp.so.6.0.0

note, there is nothing special about float 418, it was output to the file in a similar loop and is only a fraction of the way into the file.


I am wondering whether this is likely to be a problem with my code or a problem with a dependency/libstd.


Liam

quantum_leaf 03-02-2010 01:46 PM

seems ive solved it. the array wasnt being initialised (allocated) properly.


All times are GMT -5. The time now is 10:16 AM.