Getting an error message when closing my app - since oF0.06

Hi,

I moved one of my project from a svn version of oF from january [early .06], to the preRelease of oF0.06. Everything is woking. I’m just now getting an error message when i quit the application.

  
  
openFrameworksDebug(13935,0xa07d5720) malloc: *** error for object 0x873e04: Non-aligned pointer being freed  
*** set a breakpoint in malloc_error_break to debug  
openFrameworksDebug(13935,0xa07d5720) malloc: *** error for object 0x874604: Non-aligned pointer being freed  
*** set a breakpoint in malloc_error_break to debug  
ofxThread: thread already stopped  
  

Is that linked to the ofxThread ? I do not get the message “ofxThread: thread stopped” before the “ofxThread: thread already stopped”.

any ideas ?

Thanks.

yes, in 006 we try to delete the testApp before actually exiting so surely you have a pre 006 main.cpp with:

  
testApp app;  
ofRunApp(&app);  

instead of:

  
ofRunApp(new testApp);  

trying to delete an object created in the stack is what is throwing that error

Hi Arturo,

Thanks for the reply.

My main.cpp seems to up to date.

  
  
int main( ){	  
	ofAppGlutWindow window;  
	ofSetupOpenGL(&window, WIDTH,HEIGHT, OF_WINDOW);			// <-------- setup the GL context  
	  
	// this kicks off the running of my app  
	// can be OF_WINDOW or OF_FULLSCREEN  
	// pass in width and height too:  
	ofRunApp( new testApp());  
	  
}  
  

I don’t know if this is link to the error message, but why do I get “ofxThread: thread already stopped” even beore getting “ofxThread: thread stopped” ?

can you post some code, mainly related to how is the thread created, started and stopped.

After running some tests this morning, I in fact don’t think that this error is linked to the use of ofxThread. I don’t have the message “ofxThread: thread already stopped” anymore. [I was not setting correctly one of the params of my app].

I’m now just getting the error about the “Non-aligned pointer being freed”.

I found what is producing this error.
It’s when I’m deleting a pointer to an ofPoint.

I have reproduced this in a “emptyExample” project.

Here is the testApp.h where i create an instance of the class “myObject”

  
  
....  
  
#include "ofMain.h"  
#include "myObject.h"  
  
class testApp : public ofBaseApp{  
  
	public:  
		void setup();  
		void update();  
		void draw();  
  
		void keyPressed  (int key);  
		void keyReleased(int key);  
		void mouseMoved(int x, int y );  
		void mouseDragged(int x, int y, int button);  
		void mousePressed(int x, int y, int button);  
		void mouseReleased(int x, int y, int button);  
		void windowResized(int w, int h);  
	  
		myObject newObj;  
  
};  
  

and here is the class “myObject.h”

  
  
class myObject{  
	  
public:  
	  
	ofPoint* myPt;  
	  
	//--------------------------  
	myObject(){  
		myPt = new ofPoint[10 * 10];  
	}  
	  
	~myObject(){  
		printf("myObject:: KILL\n");  
		delete myPt;  
	}  
	  
};  
  
#endif  
  

and this produces the error message when quitting the application.
Am I doing something wrong ?

can you try:

  
delete [] myPt;  

instead of

  
delete myPt;  

thanks!
zach

It works. Thanks.

Now I need to understand :). This pointer does not refer to an array. Why the empty brackets before the pointer ?

well, it’s actually an array. when you call:

myPt = new ofPoint[10 * 10];

you are creating a 100 positions array of points. so you need to delete it with:

delete[]

Crap! This is what happens when you don’t look at the code correctly [without thinking].
Even if it was written “new ofPoint[10 * 10]”, I was in my head seeing “new ofPoint(10, 10)”.
Sorry about that.

Now my question becomes [even if does not really matters :], why was it not throwing the error with the version oF from mid-january ?

perhaps it has nothing to do with oF but with some update of gcc/xcode? have you tried with the same version recently?

Yes, I’m running both versions of the app. And I’m not getting the error with oF from mid january.