SIGABRT error surprisingly appeared

Sorry I cannot give you a more clear headline, but i just don’t understand it better.

I use:
OSX 10.6.8
oF 007 (also tested in 0071)
Xcode 3.2.4

When I try to run my project, it crashes after several seconds (sometimes it takes longer, sometimes shorter), and then I get this message:

  
Assertion failed: (LEQ( **(i+1), **i )), function pqInit, file /Users/theo/Documents/CODE/__OPENFRAMEWORKS/SANDBOX/COMPILE_LIBRARIES/tess/src/Sources/priorityq.c, line 413.  
Program received signal:  “SIGABRT”.  
sharedlibrary apply-load-rules all  
warning: Could not find object file "/Users/theo/Documents/CODE/__OPENFRAMEWORKS/gitOF/openFrameworks/apps/devApps/macDragDropExample/buildGlutFrameworkHackedWindowLevel10.4/libForeground.a(macx_foreground.o)" - no debug information available for "/Users/mcast/Code/GLUT-ToPost/macx_foreground.m".  

I searched for the file “priorityq.c” and couldn’t find it anywhere. Also I have no user named “theo”.
Is this maybe a relict from a library theo made?

I use ofxVectorGraphics & ofxSVGTiny.

The weird thing is, that even code that was compiled yesterday without any issue, gets the same error now. (wtf?)
I downloaded and installed a several fresh versions of openframeworks (007 & 0071), because i assumed that i might broke it somehow.

But it is weird, because i never got the error before.

Could it be a memory-issue? I checked my arrays and variables, and could not find something that could blow the code up. Also, then it must have happened before, too, because my code did not change.
Strange! I feel like it must be obvious and simple, but i just cannot see it!
Maybe someone can provide me with some insight?

In case you want to know what my application does:
I load svg-fonts and interpolate them on the fly, so that i can morph a serif-font into a sans-serif-font smoothly from the beginning of a page to the end.

here’s my main.cpp:

  
// this file sets up the box  
  
#include "ofMain.h"  
#include "testApp.h"  
#include "ofAppGlutWindow.h"  
  
//========================================================================  
int main( ){  
  
    ofAppGlutWindow window;  
	ofSetupOpenGL(&window, 1024,768, 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());  
  
}  
  

testApp.h

  
#pragma once  
  
#include "ofMain.h"  
#include "ofBall.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);  
		void dragEvent(ofDragInfo dragInfo);  
		void gotMessage(ofMessage msg);  
	  
	  
	// here some variables are introduced, they will be explained when used  
	int screenWidth;  
	int screenHeight;    
	int dimspX;  
	int dimspY;  
	int lettercount;  
	int msX;  
	int msY;  
	  
	ofxVectorGraphics output;  
	  
	bool savePDF;  
	bool savePDF1;  
  
	  
private:  
	  
	ofBall** myBallA;  
	  
	  
	int nBallsX;	// amount rows  
	int nBallsY;	// amount lines  
	int nBalls;		// amount balls  
  
		  
};  
  

testApp.cpp

  
// In this file, all variables and functions used   
  
  
#include "testApp.h"  
  
#include "ofxVectorGraphics.h"  
#include "ofxSVGTiny.h"  
  
  
ofxSVGTiny svg;  
ofxSVGTiny svg2;  
ofxSVGTiny font1;  
ofxSVGTiny font2;  
ofxSVGTiny font3;  
  
  
  
  
//--------------------------------------------------------------  
void testApp::setup()  
{  
	  
	svg.load("svg_r_2.svg");		// this is font1  
	svg2.load("svg_r_1.svg");		//this is font2  
  
	ofSetVerticalSync(true);  
	ofSetFrameRate(30);  
	  
	ofBackground(255);  
	ofSetColor(0);  
	  
	screenWidth = ofGetScreenWidth();  
	screenHeight = ofGetScreenHeight();  
	  
	dimspX = 60;		// Character space  
	dimspY = 100;		// Lineheight  
	  
	nBallsX = (screenWidth/dimspX)-6;				//*2 because i will translate screenwidth for smaller textsize  
	nBallsY = (screenHeight/(dimspY))-1;  
  
	nBalls = nBallsX*nBallsY;   
	// red balls  
	int k = 0;  
	myBallA = new ofBall*[nBalls];  
	for (int i = 0; i < nBallsY; i++){  
		for (int j = 0; j < nBallsX; j++) {  
			  
			float x = (dimspX*j);  
			float y = ((dimspY)*i);  
			  
			myBallA[k] = new ofBall(x,y,nBalls);  
			k++;  
			  
		}  
	}  
	lettercount=0;  
	  
	savePDF = false;  
	savePDF1 = false;  
  
	  
}  
  
//--------------------------------------------------------------  
void testApp::update()  
{  
	for (int i = 0; i < nBalls; i++){  
		myBallA[i]->update(1);  
	}  
	  
}  
  
//--------------------------------------------------------------  
void testApp::draw()  
{  
	if( savePDF ){  
		ofBeginSaveScreenAsPDF("screenshot-"+ofGetTimestampString()+".pdf", true);  
  
	}  
	//  
//	string msg = string("This");  
//	msg += "\nfps: " + ofToString(ofGetFrameRate(), 2);  
//	ofSetHexColor(0xFF8080);  
//	ofDrawBitmapString(msg, 10, 20);  
		  
	for (int i = 0; i < nBalls; i++){  
		myBallA[i]->draw(i,0,0,0,6,nBalls,svg,svg2);  
	}  
  
	if( savePDF ){  
		ofEndSaveScreenAsPDF();  
		savePDF = false;  
//		endsavePDF = false;  
  
	}  
}  
  
//--------------------------------------------------------------  
void testApp::keyPressed(int key)  
{  
	if(key!='0'){  
	myBallA[lettercount]->keyPressed(key, lettercount);  
	lettercount++;  
	}  
	if (lettercount>=nBalls){  
		lettercount=0;  
	}  
	  
	if(key=='0'){  
		savePDF = true;  
	}  
}  
  
//--------------------------------------------------------------  
void testApp::keyReleased(int key)  
{  
}  
  
//--------------------------------------------------------------  
void testApp::mouseMoved(int x, int y)  
{  
	myBallA[lettercount]->mouseMoved(x, y);  
  
}  
  
//--------------------------------------------------------------  
void testApp::mouseDragged(int x, int y, int button)  
{  
  
}  
  
//--------------------------------------------------------------  
void testApp::mousePressed(int x, int y, int button)  
{  
  
}  
  
//--------------------------------------------------------------  
void testApp::mouseReleased(int x, int y, int button)  
{  
  
}  
  
//--------------------------------------------------------------  
void testApp::windowResized(int w, int h)  
{  
  
}  
  
//--------------------------------------------------------------  
void testApp::gotMessage(ofMessage msg)  
{  
  
}  
  
//--------------------------------------------------------------  
void testApp::dragEvent(ofDragInfo dragInfo)  
{  
  
}  

ofBall.h // yes, I did not rename it after raping its ingredients :wink:

  
  
  
#ifndef _OF_BALL		// by using this if statement you prevent the class to be called more than once - in other words what we're saying here is   
#define _OF_BALL		//if the class has NOT been defined then define it  
  
				  
#include "ofxVectorGraphics.h"  
#include "ofMain.h"  
#include "ofxSVGTiny.h"  
  
  
class ofBall {  
  
	    
   public:     
  
		// methods  
		void update(int col);  
		void draw(int num, int r, int g, int b, float dick, int ran, ofxSVGTiny svg, ofxSVGTiny svg2);  
		void mouseMoved(int x, int y );  
		void keyPressed(int key, int lettercount);  
  
		//constructor  
		ofBall(float pX, float pY, int dim);  
  
		// variables  
		float pX;  
		float pY;  
		int letterAmount;  
		float speedX;  
		float speedY;  
		float msX;	// mouse X  
		float msY;	// mouse Y  
		int range;	// range of mouse magnetics  
		char letter[];  
		char randomness[];  
		int lettercount;  
	  
		bool snapBack; // toggle drawing mode  
	  
		ofxVectorGraphics output;  
		bool capture;  
		bool bFill;  
	  
	// my super variables  
	float	vvHereX;  
	float	vvHereY;  
	float	vvHereZ;  
	float	tweenCount;  
	bool	countUp;  
	bool	svgLoad;  
	  
	int		svgNum;  
  
	  
	bool	savePDF;  
	bool	endPDF;  
	  
	//int		timeCount;  
	  
	bool aniSinus;  
	  
	  
	private:  
   
     
};						//don't forget the semicolon in the end of the class definition  
  
#endif   

ofBall.cpp

  
  
  
#include "ofBall.h"  
#include "ofxSVGTiny.h"  
  
  
  
ofBall::ofBall(float posX, float posY, int _letterAmount)  
{  
	  
	pX = posX;				// this tells me, where to place the letter x-wise  
	pY = posY;				// this tells me, where to place the letter y-wise  
//	  
	letterAmount = _letterAmount;				// this tells me how many letters there are   
	msX=0;					// unnecessary yet  
	msY=0;					// unnecessary yet  
//	  
//	range = 60;				// magnet range				// unnecessary yet  
	  
//	capture = false;				// necessary yet  
	bFill	= true;			// not working yet  
	  
	tweenCount = 0;				// necessary? yes! yes! this is the value controlling interpolation  
//	countUp=true;				// necessary? no!  
//	svgLoad=true;				// necessary? not anymore  
	  
	for (int i=0; i<letterAmount; i++){	// "letter" is the array that stores which letter should be on which position.  
		letter[i] = ' ';		// it starts with emptiness everywhere  
	}  
	  
	savePDF = false;			// trying to export as pdf, not working yet  
	endPDF = false;				// trying to export as pdf, not working yet  
		  
	aniSinus=false;				// if set to "true", the interpolation is animated in a loop  
}  
  
  
void ofBall::update(int col){  
	  
}  
  
void ofBall::draw(int num, int r, int g, int b, float dick, int ran, ofxSVGTiny svg, ofxSVGTiny svg2){  
  
	  
	//do we want filled shapes or outlines? -> does not work yet  
//	if(bFill)output.fill();  
//	else output.noFill();  
	  
	if(aniSinus){  
		float sinum = num+10*ofGetElapsedTimef();  
		tweenCount = (sin(sinum/6)+1)/2; // ... +1)/2 -> schiebt sinus nach oben und halbiert, damit 1 das maximum ist fürs interpolieren  
	} else {  
		float sinum = num;  
		tweenCount = 1-(sinum/ran);		// interpolating from start to end  
	}  
	  
	svgNum=toascii(letter[num])-96;		// here i am converting the value i get from the keyboard to ascii, for getting the right letter  
	if (svgNum>=27||svgNum<=0){			// if the value is out of range  
		svgNum=0;						// make it emptiness  
	}  
		  
		for (int i = 0; i < svg.getNumPath(); i++)  
		{  
			  
			ofPath &p = svg.getPathAt(svgNum);			// first font: svgNum toggles svg-layer/letter  
			ofPath &p2 = svg2.getPathAt(svgNum);		// second font: dito   
			  
			vector<ofPolyline>& lines = p.getOutline();		// getOutline() says it. store it in "line" and "line2"  
			vector<ofPolyline>& lines2 = p2.getOutline();  
			  
			for (int k = 0; k < lines.size(); k++)			// there are a lot of lines. size tells you how many  
			{  
				ofPolyline line = lines[k];					// for every line in "lines", the loop will run once  
				ofPolyline line2 = lines2[k];				// same here  
				  
//				int num = ((1-tweenCount)*line.size())+(tweenCount*line2.size());		//former attempt of interpolation				// original: int num = step * line.size();  
							  
				  
//				glBegin(GL_LINE_STRIP);		// enable openGL rendering, later hopefully able to render filled letters  
				ofFill();  
//				ofNoFill();  
				ofEnableAlphaBlending();  
				ofSetColor(255,255,255);  
				if(k==0){  
					ofSetColor(0,0,0);  
				}  
//				ofSetLineWidth(2);  
				ofBeginShape();  
				for (int j = 0; j < line.size(); j++)  
				{  
  
					ofVec3f &vv = line[j];  
					ofVec3f &vv2 = line2[j];  
					  
					vvHereX = pX+((1-tweenCount)*vv.x)+(tweenCount*vv2.x);		// simple interpolation from one   
					vvHereY = pY+((1-tweenCount)*vv.y)+(tweenCount*vv2.y);  
					vvHereZ = 0;												// experimental 3Dimensional value  
					  
					ofVertex(vvHereX, vvHereY);						// actually draw the letter  
				}																// experimantel 3d: vvHereZ+ofRandom(msX));  
				ofEndShape();  
				ofDisableAlphaBlending();  
//				glEnd();  
			}  
		}  
  
  
}   
  
void ofBall::mouseMoved(int x, int y ){  
	  
	// mouseposition for later interaction  
	msX = x;  
	msY = y;  
	cout << "msX" << msX << endl;;  
  
}  
  
//--------------------------------------------------------------  
void ofBall::keyPressed  (int key, int lettercount){  
	  
	letter[lettercount] = key;  
  
}  
  

Thanks a lot!

Hi,

such errors occurs for example when you are using uninitialised variables, or when writing stuff outside the bounds/size of variables.

Here you are not initializing the letter-array. Generally speaking you should add some range-checking, if array-indices are valid, etc. And use std::vector instead of plain c-arrays.

HTH,

Stephan

1 Like

Dear Stephan,

Dankeschön for having a look and extending my vocabulary :wink:

I’m relieved, what you said makes sense and sounds very normal and fixable.

greetings,
Jakob

// now, after several days/hours of testing:
Is there a way to see which array or variable causes the error?

I could not solve it…
what i don’t understand is, that I believe to initialize the letter-array in ofBall.h, don’t i?

Also if I do initialize it with a randomly high number to make sure that it is not accessed out of range

  
	private:  
		char letter[244];  

it has no no effect.

I tried to initialize it directly in the ofBall.cpp, too.

also, how do i do this range-checking and see if array-indices are valid?

// several more hours of testing:

I tried to use a vector instead of a plain array.

This is how I introduce it in ofBall.h

  
class ofBall {  
  
   public:     
	vector<int> letters;  

This is how I use it in ofBall.cpp

  
[...]  
#include <vector>  
  
ofBall::ofBall(float posX, float posY, int _letterAmount)  
{  
	letterAmount = _letterAmount;				// this tells me how many letters there are   
	  
[...]  
  
	int nichts = toascii(' ');  
	for (int i=0; i<letterAmount; i++){	// "letters" is the vector that stores which letter should be on which position.  
		letters.push_back(nichts); // add a space on each position  
	}  
	cout << letters.size() << "setup" << endl;  
}  
  
  
void ofBall::draw(int num, int r, int g, int b, float dick, int ran, ofxSVGTiny svg, ofxSVGTiny svg2){  
	  
	cout << letters.size() << "startDraw" << endl;  
  
	  
	//do we want filled shapes or outlines? -> does not work yet  
//	if(bFill)output.fill();  
//	else output.noFill();  
	  
//	if(aniSinus){  
//		float sinum = num+10*ofGetElapsedTimef();  
//		tweenCount = (sin(sinum/6)+1)/2; // ... +1)/2 -> schiebt sinus nach oben und halbiert, damit 1 das maximum ist fürs interpolieren  
//	} else {  
		float sinum = num;  
	tweenCount = 1-(sinum/ran);		// interpolating from start to end  
//	}  
//	cout << letters.max<< "and here went the vecotr" << endl;;  
	cout << letters.size() << "mittelDraw" << endl;  
  
	svgNum=letters[num];		// here i should get the right letter  
	if (svgNum>=27||svgNum<=0){			// if the value is out of range  
		svgNum=0;						// make it emptiness  
	}  
	cout << letters.size() << "mittelDraw" << endl;  
  
		// i erased the part where the thing is drawn, because it did not change from the above  
  
	cout << letters.size() << "endDraw" << endl;  
  
}   
  
[...]  
//--------------------------------------------------------------  
void ofBall::keyPressed  (int key, int lettercount){  
	  
	letters[lettercount] = toascii(key);  
  
}  
  

the cout:

  
104setup  
... repeats 104 times for each instance of ofBalls()  
104startDraw  
104startDraw  
104mittelDraw  
104mittelDraw  
104endDraw  
... goes on like this for a while  
104startDraw  
104mittelDraw  
104mittelDraw  
104endDraw  
4103859836startDraw  
4103859836mittelDraw  
4103859836mittelDraw  
4103859836endDraw  
223543249startDraw  
Program received signal:  “EXC_BAD_ACCESS”.  
sharedlibrary apply-load-rules all  
warning: Could not find object file "/Users/theo/Documents/CODE/__OPENFRAMEWORKS/gitOF/openFrameworks/apps/devApps/macDragDropExample/buildGlutFrameworkHackedWindowLevel10.4/libForeground.a(macx_foreground.o)" - no debug information available for "/Users/mcast/Code/GLUT-ToPost/macx_foreground.m".  

Hi Jakob,

Have you solved the problem?
I’m facing similar assertion failure.
The priorityq.c file can be found under libs/tess2/sources.
The line 413 is

if(! LEQ( **(i+1), **i )) return 0;

The assertion is hidden somewhere behind the LEQ which is defined as following

#ifdef FOR_TRITE_TEST_PROGRAM
#define LEQ(x,y)	(*pq->leq)(x,y)
#else
/* Violates modularity, but a little faster */
#include "geom.h"
#define LEQ(x,y)	VertLeq((TESSvertex *)x, (TESSvertex *)y)
#endif

I didn’t investigate any further since I found your post.

I suspect that assertion fails when an ofVertix() is placed far beyond screen boundaries.
What was your resolution?

Regards,
Victor

this looks like a bad memory allocation thing – for example, calling an object that doesn’t exit (off by one error, etc) – these numbers look quite off. if you have an array of 10 objects, but you call the eleventh one, you will get some random chunk of memory which will produce strange results.

can you post the full code (as simple as possible) that crashes somewhere?

sure, i’ll try to dig it up.

though, recalling my memory i’m quite sure i didn’t solve it, but just worked a way around it somehow.

Here what I tried to do: My goal was to interpolate between typefaces, so i was using a vector of chars to store the order of letters. As a key was pressed I pushed each keyCode in the vector, or iterated through the letters of a drag/dropped file. I used an array of chars for this initially, until someone suggested wisely I should use a vector. Though, that didn’t stop the occasional sigabrt error.

I’m quite sure I didn’t draw vertices outside of the screen boundaries, but it sounds possible to call an index greater that the size of the vector/array.

here I’m told that something is badly accessed:
... Program received signal: “EXC_BAD_ACCESS”. ...

this could be an index out of range, but what is the connection to the following file?
... warning: Could not find object file "/Users/theo/Documents/CODE/__OPENFRAMEWORKS/gitOF/openFrameworks/apps/devApps/macDragDropExample/buildGlutFrameworkHackedWindowLevel10.4/libForeground.a(macx_foreground.o)" ...

I’m not theo, and it seems like an absolute path like this certainly shouldn’t be showing up.

But I have no idea how this correlates with the size of the vector/array.
Give me a day, i’m on my way to work now, i have the code at home somewhere. I’ll try to post a simple crashing version of it as soon as i can get hands on it.

the reason you are seeing this path is that theo compiled this library (libForeground.a) – when the app crashes, gdb starts to look for debug info to tell you more info, sometimes libs can have paths baked into the them, that help the debugger look for that info. In this case, it can’t find that original file from theo’s hard drive, so it complains. In most cases, the crash isn’t in that lib so it’s not a huge deal, it’s just a side effect of using object code someone else has compiled.

1 Like

ah, alright that makes sense. thanks zach.

so, I unfortunately didn’t keep a crashing version.
but, looking at the snippets i posted it makes totally sense what stephan and zach thought.

first, the vector of integers to store the ascii-values of all letters

vector<int> letters;

then an instance of ofBall is created, with a fixed amount of letters.

ofBall::ofBall(float posX, float posY, int letterAmount)
{
[...]
	int nichts = toascii(' ');
	for (int i=0; i<letterAmount; i++){
		letters.push_back(nichts); // add a space on each position
	}
}

with each key pressed, the ascii-value of the pressed key is written in the vector.
the index is given with “lettercount”. Unfortunately I cannot retrieve how this was calculated… for sure it was not supposed to become 4103859836, but when it did, probably this one resulted in the SIGABRT
though, it’s a pity that i can’t reproduce it, because this would’ve been the interesting part…

//--------------------------------------------------------------
void ofBall::keyPressed  (int key, int lettercount){
	letters[lettercount] = toascii(key); // lettercount possibly greater than vector -> crash
}

or it could have happened in the draw(), unfortunately also here i don’t know how it was called exactly and where the “num” comes from.

void ofBall::draw(int num, [...] ){
	svgNum=letters[num];	//  num possibly greater than vector -> crash
}

so… no idea if this helps. i feel kind of ashamed to post this code (again) because it’s not very elegant on many levels, but i gladly sacrifice my name if someone might be prevented from doing the same mistakes :wink: