Re: Segmentation fault (fwd)

From: Billy H. Chan (~{3B:FH;~}) (bhchan@csua.berkeley.edu)
Date: 09/18/95


You recently wrote:
> On Mon, 18 Sep 1995, Rasmus Rxnlev wrote:
> > The problem arises when I transfer the sourcecocode to the remote mashine 
> > (SunOS), the source still compiles without errors, and seemingly runs fine...
> > 
> > BUT, MOSTLY when fighting, sometimes even when the mud is more or less 
> > idle it CRASHES ... the program returns "Segmentation Fault"..
> > 
> > NOW, considering this I thought... Well.. Has to be my code.. BUT, 

Heh, the same thing happened to me, but reversed.  I code on my Sparc
station LX and my co-coder/helper/whatever has a linux up (I'm setting
up my pentium to do linux sometime this week).  I ftp'ed the tree to
him and he compiled and started running bin/circle.... funny thing was,
he kept getting a segfault while doing character creation.  My sparc
didn't get that and it was the same code verbatim.

Ends up, while rerererewriting (that's 4 times) the character generation
code, I had tried to use a secondary 'for' loop inside the first for rolling
attributes.  I used 'j' for the index.  A few times later, I decided to
remove the first layer of 'for' (at one point, I had three nested 'for's
with i, j, k doing counting respectively). And while rewriting, I accidently
had this:
 	while (m < MIN_ATTRIBUTE_AVE) {
	  for (m = 0, i = 0; j < 6; i++) {
	          for (j = 0; j < 4; j++)
	            rolls[j] = number(1, 6);
	          table[i] = rolls[0] + rolls[1] + rolls[2] + rolls[3] -
	                MIN(rolls[0], MIN(rolls[1], MIN(rolls[2], rolls[3])));
	          m += table[i];
	        }
	  m = (int) (m / 6);
	  }
 
A very cameflaghed(sp) bug that somehow got through my Sparc.  (the bug's
in the first for loop, if you didn't catch it).

So, point of story: 
	1) strange things happen across platforms
	2) check them one-letter-variables (OLVs)

good luck bug hunting....(I usually end up with a one to one ratio of
log to code) :)



This archive was generated by hypermail 2b30 : 12/07/00 PST