Hi ,
When i am writing to a file continuously I am getting this error.
*** glibc detected *** ./MITE_Project2_Exe: free(): invalid next size (normal): 0x0000000028ba02f0 ***
======= Backtrace: =========
/lib64/libc.so.6[0x33c2c71cec]
/lib64/libc.so.6(cfree+0x8c)[0x33c2c7590c]
./MITE_Project2_Exe[0x40fe98]
./MITE_Project2_Exe[0x4124ce]
./MITE_Project2_Exe[0x4128de]
./MITE_Project2_Exe[0x414bf8]
./MITE_Project2_Exe[0x41560f]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x33c2c1d974]
./MITE_Project2_Exe(__gxx_personality_v0+0xd1)[0x402a79]
======= Memory map: ========
00400000-0041f000 r-xp 00000000 00:17 10600310 /home/csgrad/heratyag/new/MITE_Project2_Exe
0061f000-00620000 rw-p 0001f000 00:17 10600310 /home/csgrad/heratyag/new/MITE_Project2_Exe
13433000-28baa000 rw-p 13433000 00:00 0 [heap]
33c2400000-33c241c000 r-xp 00000000 fd:00 63491 /lib64/ld-2.5.so
33c261b000-33c261c000 r--p 0001b000 fd:00 63491 /lib64/ld-2.5.so
33c261c000-33c261d000 rw-p 0001c000 fd:00 63491 /lib64/ld-2.5.so
33c2c00000-33c2d4c000 r-xp 00000000 fd:00 63494 /lib64/libc-2.5.so
33c2d4c000-33c2f4c000 ---p 0014c000 fd:00 63494 /lib64/libc-2.5.so
33c2f4c000-33c2f50000 r--p 0014c000 fd:00 63494 /lib64/libc-2.5.so
33c2f50000-33c2f51000 rw-p 00150000 fd:00 63494 /lib64/libc-2.5.so
33c2f51000-33c2f56000 rw-p 33c2f51000 00:00 0
33c3000000-33c3082000 r-xp 00000000 fd:00 63509 /lib64/libm-2.5.so
33c3082000-33c3281000 ---p 00082000 fd:00 63509 /lib64/libm-2.5.so
33c3281000-33c3282000 r--p 00081000 fd:00 63509 /lib64/libm-2.5.so
33c3282000-33c3283000 rw-p 00082000 fd:00 63509 /lib64/libm-2.5.so
33c8000000-33c800d000 r-xp 00000000 fd:00 63515 /lib64/libgcc_s-4.1.2-20080825.so.1
33c800d000-33c820d000 ---p 0000d000 fd:00 63515 /lib64/libgcc_s-4.1.2-20080825.so.1
33c820d000-33c820e000 rw-p 0000d000 fd:00 63515 /lib64/libgcc_s-4.1.2-20080825.so.1
33c8800000-33c88e6000 r-xp 00000000 fd:03 2687243 /usr/lib64/libstdc++.so.6.0.8
33c88e6000-33c8ae5000 ---p 000e6000 fd:03 2687243 /usr/lib64/libstdc++.so.6.0.8
33c8ae5000-33c8aeb000 r--p 000e5000 fd:03 2687243 /usr/lib64/libstdc++.so.6.0.8
33c8aeb000-33c8aee000 rw-p 000eb000 fd:03 2687243 /usr/lib64/libstdc++.so.6.0.8
33c8aee000-33c8b00000 rw-p 33c8aee000 00:00 0
2afe0367e000-2afe03680000 rw-p 2afe0367e000 00:00 0
2afe036a3000-2afe036a6000 rw-p 2afe036a3000 00:00 0
2afe03768000-2afe037e9000 rw-p 2afe03768000 00:00 0
2afe04000000-2afe04021000 rw-p 2afe04000000 00:00 0
2afe04021000-2afe08000000 ---p 2afe04021000 00:00 0
7fff5ca28000-7fff5ca3d000 rw-p 7ffffffea000 00:00 0 [stack]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vdso]
Abort
My program is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <iostream>
#include <fstream>
#include <string>
#include <sys/stat.h>
#include <list>
#include "BinaryIO.h"
using namespace std;
BinaryIO :: BinaryIO(size_t sz)
{
data = new char[sz];
}
BinaryIO :: BinaryIO()
{
data = new char[150];
}
void BinaryIO :: writeBinFile(string filePath,list <unsigned long> writeData,ofstream& file)
{
struct stat buffer;
BinaryIO binWriteData;
ifstream::pos_type size;
int status;
list <unsigned long> :: iterator itr;
size = file.tellp();
for(itr = writeData.begin();itr != writeData.end();itr++)
{
sprintf(data,"%lu",*itr);
memset(data,' ',150);
file.write(reinterpret_cast<char *>(&binWriteData),sizeof(BinaryIO));
}
}
|
Please Help
Thanx in advance.