www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/24/13:16:17

From: Andy Maddison <maddison AT coventry DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: I'm going slightly mad!!
Date: Tue, 24 Feb 1998 10:45:45 +0000
Organization: Coventry University
Lines: 63
Message-ID: <Pine.OSF.3.91.980224095752.136A-100000@leofric>
NNTP-Posting-Host: leofric.coventry.ac.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I've been using DJGPP for a while now, just basic C++ 3d graphics 
programming, and everything has been going quite well.  But now I've run 
into some strange problems:

When I execute my current piece of work I sometimes get a General 
Protection Fault or Floating Point Error, but not everytime!
So why does an unchanged program crash periodically?

Stranger still:  I've had the above errors occur when I've simply invoked 
gcc to compile my program (for the first time), i.e. gcc crashed without 
compiling, but on subsequent attempts all went well with compilation and
linking (gxx).  But then my program crashed again.

I've used gdb which imforms me where the error occurs but I've checked 
the code and there shouldn't be a problem, I've called the same function 
many times before with the same argument types and all went as expected.

I've also had an older program crash (with similar errors) when I 
executed it during the same session, but it has always worked with no 
problems.

The current program reads some tri-mesh data from a text file, i.e. 
vertex and face information, and creates new instances of vertices (200+) 
and polygons (400+).  The number of vertices and faces is read at the 
beginning of the file.  So the code looks something like this:

read number of vertices and faces from file

Vertex** v = new Vertex*[vertices];
Polygon** p = new Polygon*[faces];

for(int i=0;i<vertices;i++)
{
	read vertex coordinates x,y,z from file
	v[i] = new Vertex(x,y,z);
}

for(int i=0;i<faces;i++)
{
	read polygon vertices v1,v2,v3 from file
	p[i] = new Polygon(v[v1],v[v2],v[v3]);
}

I've inserted statements within the loop to print out the data as it is 
read just to double check that it is being read correctly - and it is!

Could the problem be memory related?

I'm running Windows95 and I've got 32Mb in my machine, is this automatically 
used by my program?

Due to the use of edge lists for storing the polygon's data, each polygon 
takes up in excess of 3k.  But I'm freeing this memory when each 
polygon is destroyed.

The funny thing is that I've tried commenting out various different parts of 
the code and recompiling, but I can't seem to narrow the error down to a 
specific line of code.  I've also tried using hard coded values for the 
vertices and polygons, i.e. not reading from the file at all.

If you can throw some light on this situation, then please do. 
  
Thanks.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019