• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A malloc error in C++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A malloc error in C++


  • Subject: Re: A malloc error in C++
  • From: Giacomo Monari <email@hidden>
  • Date: Wed, 29 Aug 2007 17:15:05 +0200


Aaron Montgomery ha scritto:
Hi Giacomo,

Looks like the destructors for your data analysis class objects are being called twice. Once explicitly by you and a second time (as they go out of scope). Since they all go out of scope after you reach the end of main. This is consistent with the "error happens after the program has done its work."

Either remove the explicit destruction, or if required, place each analysis run inside its own scope by adding { and }. See below for the first case.

On Aug 29, 2007, at 7:13 AM, Giacomo Monari wrote:

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...

<snipped start up code>

//add open brace here so zAnalysis lives in its own scope.
{


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;

//add a close brace here to clean up zAnalysis }

//remove this line
//    zAnalysis.~DataAnalysis();

//repeat for each Analysis object

Hope that helps,

Aaron

Clark Cox ha scritto:
Here's your problem. Why are you trying to call the destructor directly?

Thx and sorry guys but still doesn't work. Before I forgot to say that I added those calls to the destructors only to see if something would have changed, but it didn't...
Removing them and also adding the braces, Aaron, brings no changes... :(
What could be?
Giacomo



-- Email.it, the professional e-mail, gratis per te: http://www.email.it/f

Sponsor:
Prestiti da 1.500 a 30.000 Euro. Clicca qui per un preventivo immediato, richiedi subito lÂ’importo e la rata che desideri, con Prometeo basta un clic!
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=6918&d=29-8
_______________________________________________
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


  • Follow-Ups:
    • Re: A malloc error in C++
      • From: Giacomo Monari <email@hidden>
    • Re: A malloc error in C++
      • From: Lyndsey Ferguson <email@hidden>
  • Prev by Date: Re: A malloc error in C++
  • Next by Date: Re: Unrecognized ld flags
  • Previous by thread: Re: A malloc error in C++
  • Next by thread: Re: A malloc error in C++
  • Index(es):
    • Date
    • Thread