Re: AAIGH! Explain...

From: Tel Janin Aellinsar (icarus@Loomis.Berkshire.NET)
Date: 04/10/96


On Wed, 10 Apr 1996, Hades wrote:

> My mud now keeps crashing, no doubt to the new code I;ve imped, but gdb says
> it is crashing here in handler.c:
> 
> void obj_to_char(struct obj_data *object, struct char_data *ch)
> {
>   if (object && ch) {
>     object->next_content = ch->carrying;  <- HERE! HOW?
>     ch->carrying = object;
>     object->carried_by = ch;
> 
> How can it crash at that line? The if statement right before it checks to
> see if object & ch != NULL. How can that crash it? Might I have some
> funky-ass memory leak?

Well, I've noticed that on some (stupid) gcc's, the program will try to 
continue operation after a memory error that should really cause a 
crash.  The idea behind this, I guess, is to skip past all of the NULL 
pointer references that are technically illegal but don't usually cause a 
big problem.  The difficulty is that sometimes all it takes is a 
reference to a memory pointer after a while to cause a crash which is 
then almost totally unidentifiable.  In tracking down these problems, 
I've found the bounds-checking library to be of immense use.  It means 
that it'll crash CircleMUD every other line of code, but damn it if you 
won't have clean code three years later, when you've fixed all the bugs!

The problem with this is that if your machine hasn't got bounds checking 
already, you have to download the sources for gcc and recompile them, 
which takes 60mb of disk space and superuser access unless you know 
something I don't.  But you can try.  Look for a library called bounds.a 
to see if you've at least got the linkable library.  If you do, recompile 
all of CircleMUD using -fbounds-checking and turn off all the 
optimizations.  Crank up debugging the whole way.

You'll have to cope with the bounds-checking copyright at the startup of 
CircleMUD, but you can get rid of that once you've spotted all the 
areas.  Also, bounds should catch any bugs the first time around, rather 
than every 5 hours or so.

________________________________________________________________________
Tel Janin Aellinsar                       http://www.crocker.com/~icarus
McCoy Enterprises Corporation          Shayol Ghul Resort and Health Spa
Berserker Dragon, Knights of the Cosmos             icarus@BERKSHIRE.NET



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