LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-02-2010, 11:59 AM   #1
quantum_leaf
LQ Newbie
 
Registered: Jul 2005
Posts: 10

Rep: Reputation: 0
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
 
Old 03-02-2010, 02:46 PM   #2
quantum_leaf
LQ Newbie
 
Registered: Jul 2005
Posts: 10

Original Poster
Rep: Reputation: 0
seems ive solved it. the array wasnt being initialised (allocated) properly.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What does this error mean? double free or corruption nanxy Programming 6 08-10-2008 12:26 PM
Urgent: glibc detected *** double free or corruption error when creating ms_newMapobj SteevN Linux - General 0 04-01-2008 08:52 AM
*** glibc detected *** double free or corruption - ERROR bandwidthjunkie Programming 2 03-19-2007 10:36 AM
Open Office user install error: *** glibc detected *** double free or corruption: 0xb r_jensen11 Linux - General 6 01-16-2005 07:08 AM


All times are GMT -5. The time now is 04:26 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration