A malloc error in C++
A malloc error in C++
- Subject: A malloc error in C++
- From: Giacomo Monari <email@hidden>
- Date: Wed, 29 Aug 2007 16:13:25 +0200
Hello everyone,
while running a program called lab3_1 written in c++ I get this in the
Run Log:
lab3_1(1517) malloc: *** error for object 0x1804400: incorrect
checksum for freed object - object was probably modified after being
freed, break at szone_error to debug
lab3_1(1517) malloc: *** set a breakpoint in szone_error to debug
lab3_1 has exited due to signal 11 (SIGSEGV).
and the debugger window pops up...
Note that this happens after the program has done its work...
What could it be? How could I resolve it?
I also include the main of my program; it basically analyzes certain
data from a file called "3cr_1.txt"...
#include
<iostream>
#include <string>
#include <fstream>
#include <vector>
#include "dataAnalysis.h"
using namespace std;
namespace GMNLFS=Giacomo_Monari_Numerical_Library_For_Simulations;
int main (int argc, char * const argv[]) {
ifstream dataFile("/Users/giacomomonari/Programmi
C++/lab3_1/3cr_1.txt");
if (dataFile.fail())
{
cout << "No data file!" << endl;
}
string dummy1;
getline(dataFile,dummy1);
dummy1.~string();
vector<double> z(0);
vector<double> mv(0);
vector<double> s178(0);
vector<double> a150(0);
vector<double> las(0);
vector<double> lls(0);
vector<double> loglb(0);
vector<double> logp178(0);
char dummy2[19];
double currentVar;
int count = 0;
while(!dataFile.eof())
{
dataFile.ignore(19,*dummy2);
dataFile >> currentVar;
z.push_back(currentVar);
dataFile >> currentVar;
dataFile >> currentVar;
mv.push_back(currentVar);
dataFile >> currentVar;
s178.push_back(currentVar);
dataFile >> currentVar;
a150.push_back(currentVar);
dataFile >> currentVar;
las.push_back(currentVar);
dataFile >> currentVar;
lls.push_back(currentVar);
dataFile >> currentVar;
loglb.push_back(currentVar);
dataFile >> currentVar;
logp178.push_back(currentVar);
count++;
}
dataFile.close();
GMNLFS::DataAnalysis<vector<double>::iterator,double>
zAnalysis(z.begin(),z.end());
cout << "Max z = " << zAnalysis.GetMax() << endl;
cout << "Min z = " << zAnalysis.GetMin() << endl;
cout << "Average z = " << zAnalysis.GetAverage()
<< endl;
cout << "Variance of z = " << zAnalysis.GetVariance()
<< endl;
cout << "Standard Deviation of z = " <<
zAnalysis.GetStdDeviation() << endl;
cout << "Skewness of z = " << zAnalysis.GetSkewness()
<< endl;
cout << "Kurtosis of z = " << zAnalysis.GetKurtosis()
<< endl;
cout << " ------------------------------------- " <<
endl;
zAnalysis.~DataAnalysis();
GMNLFS::DataAnalysis<vector<double>::iterator,double>
mvAnalysis(mv.begin(),mv.end());
cout << "Max mv = " << mvAnalysis.GetMax() <<
endl;
cout << "Min mv = " << mvAnalysis.GetMin() <<
endl;
cout << "Average mv = " << mvAnalysis.GetAverage()
<< endl;
cout << "Variance of mv = " << mvAnalysis.GetVariance()
<< endl;
cout << "Standard Deviation of mv = " <<
mvAnalysis.GetStdDeviation() << endl;
cout << "Skewness of mv = " << mvAnalysis.GetSkewness()
<< endl;
cout << "Kurtosis of mv = " << mvAnalysis.GetKurtosis()
<< endl;
cout << " ------------------------------------- " <<
endl;
mvAnalysis.~DataAnalysis();
GMNLFS::DataAnalysis<vector<double>::iterator,double>
s178Analysis(s178.begin(),s178.end());
cout << "Max s178 = " << s178Analysis.GetMax() <<
endl;
cout << "Min s178 = " << s178Analysis.GetMin() <<
endl;
cout << "Average s178 = " << s178Analysis.GetAverage()
<< endl;
cout << "Variance of s178 = " <<
s178Analysis.GetVariance() << endl;
cout << "Standard Deviation of s178 = " <<
s178Analysis.GetStdDeviation() << endl;
cout << "Skewness of s178 = " <<
s178Analysis.GetSkewness() << endl;
cout << "Kurtosis of s178 = " <<
s178Analysis.GetKurtosis() << endl;
cout << " ------------------------------------- " <<
endl;
s178Analysis.~DataAnalysis();
GMNLFS::DataAnalysis<vector<double>::iterator,double>
a150Analysis(a150.begin(),a150.end());
cout << "Max a150 = " << a150Analysis.GetMax() <<
endl;
cout << "Min a150 = " << a150Analysis.GetMin() <<
endl;
cout << "Average a150 = " << a150Analysis.GetAverage()
<< endl;
cout << "Variance of a150 = " <<
a150Analysis.GetVariance() << endl;
cout << "Standard Deviation of a150 = " <<
a150Analysis.GetStdDeviation() << endl;
cout << "Skewness of a150 = " <<
a150Analysis.GetSkewness() << endl;
cout << "Kurtosis of a150 = " <<
a150Analysis.GetKurtosis() << endl;
cout << " ------------------------------------- " <<
endl;
a150Analysis.~DataAnalysis();
GMNLFS::DataAnalysis<vector<double>::iterator,double>
lasAnalysis(las.begin(),las.end());
cout << "Max las = " << lasAnalysis.GetMax() <<
endl;
cout << "Min las = " << lasAnalysis.GetMin() <<
endl;
cout << "Average las = " << lasAnalysis.GetAverage()
<< endl;
cout << "Variance of las = " <<
lasAnalysis.GetVariance() << endl;
cout << "Standard Deviation of las = " <<
lasAnalysis.GetStdDeviation() << endl;
cout << "Skewness of las = " <<
lasAnalysis.GetSkewness() << endl;
cout << "Kurtosis of las = " <<
lasAnalysis.GetKurtosis() << endl;
cout << " ------------------------------------- " <<
endl;
lasAnalysis.~DataAnalysis();
GMNLFS::DataAnalysis<vector<double>::iterator,double>
llsAnalysis(lls.begin(),lls.end());
cout << "Max lls = " << llsAnalysis.GetMax() <<
endl;
cout << "Min lls = " << llsAnalysis.GetMin() <<
endl;
cout << "Average lls = " << llsAnalysis.GetAverage()
<< endl;
cout << "Variance of lls = " <<
llsAnalysis.GetVariance() << endl;
cout << "Standard Deviation of lls = " <<
llsAnalysis.GetStdDeviation() << endl;
cout << "Skewness of lls = " <<
llsAnalysis.GetSkewness() << endl;
cout << "Kurtosis of lls = " <<
llsAnalysis.GetKurtosis() << endl;
cout << " ------------------------------------- " <<
endl;
llsAnalysis.~DataAnalysis();
GMNLFS::DataAnalysis<vector<double>::iterator,double>
loglbAnalysis(loglb.begin(),loglb.end());
cout << "Max loglb = " << loglbAnalysis.GetMax()
<< endl;
cout << "Min loglb = " << loglbAnalysis.GetMin()
<< endl;
cout << "Average loglb = " <<
loglbAnalysis.GetAverage() << endl;
cout << "Variance of loglb = " <<
loglbAnalysis.GetVariance() << endl;
cout << "Standard Deviation of loglb = " <<
loglbAnalysis.GetStdDeviation() << endl;
cout << "Skewness of loglb = " <<
loglbAnalysis.GetSkewness() << endl;
cout << "Kurtosis of loglb = " <<
loglbAnalysis.GetKurtosis() << endl;
cout << " ------------------------------------- " <<
endl;
loglbAnalysis.~DataAnalysis();
GMNLFS::DataAnalysis<vector<double>::iterator,double>
logp178Analysis(logp178.begin(),logp178.end());
cout << "Max logp178 = " << logp178Analysis.GetMax()
<< endl;
cout << "Min logp178 = " << logp178Analysis.GetMin()
<< endl;
cout << "Average logp178 = " <<
logp178Analysis.GetAverage() << endl;
cout << "Variance of logp178 = " <<
logp178Analysis.GetVariance() << endl;
cout << "Standard Deviation of logp178 = " <<
logp178Analysis.GetStdDeviation() << endl;
cout << "Skewness of logp178 = " <<
logp178Analysis.GetSkewness() << endl;
cout << "Kurtosis of logp178 = " <<
logp178Analysis.GetKurtosis() << endl;
cout << " ------------------------------------- " <<
endl;
logp178Analysis.~DataAnalysis();
return 0;
}
Giacomo
----
Email.it, the professional e-mail, gratis per te:clicca qui
Sponsor:
Hai bisogno di contanti per realizzare i tuoi desideri? Prometeo ti propone prestiti da 1.500 a 31.000 Euro! Clicca qui per un preventivo immediato.
Clicca qui
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden