Wierd problem

Posted by Trom on Tue 24 Feb 2004 01:49 AM — 5 posts, 19,729 views.

#0
This is an error which seemed to come out of nowhere, i didn't touch the is_dark function thing and thats were the error started.

I've been doing a lot of work every day now since the last prob (which you guys helped me fix). Currently i've looked over the code in gdb, backtraced and changed it a bit to see if it was maybe a syntax thing.

Cygwin error:
Program received signal SIGSEGV, Segmentation fault.
0x00414fac in do_look (ch=0x102a95c8, argument=0x451113 "") at act_info.c:1387
1387 send_to_char ( ch->in_room->name, ch );

BackTrace:
#0 0x00414fac in do_look (ch=0x102a95c8, argument=0x451113 "")
at act_info.c:1387
#1 0x00452c9c in nanny (d=0x102a7f60, argument=0x102a88dd " ") at comm.c:3364
#2 0x0044d88f in game_loop_unix (control=4, wwwcontrol=5) at comm.c:909
#3 0x0044d118 in main (argc=1, argv=0x100213a8) at comm.c:472

The error occurs after motd is loaded (the welcome screen for mortals). It originally had to do with a dark room check, so i commented out hte entire function to see if it was that. Now it seems to point to ch->in_room variable as the error.

As for the character, on creation its allocated new_char() so it shouldnt be that type of memory error. If you have any ideas, please post.

Amended on Tue 24 Feb 2004 01:50 AM by Trom
#1
This was the function causing the error originally before i commented it out.

bool room_is_dark ( ROOM_INDEX_DATA *pRoomIndex )
{
/*if ( pRoomIndex->light > 0 )
return FALSE;

if ( IS_SET ( pRoomIndex->room_flags, ROOM_DARK ) )
return TRUE;

if ( pRoomIndex->sector_type == SECT_INSIDE ||
pRoomIndex->sector_type == SECT_CITY )
return FALSE;

if ( weather_info.sunlight == SUN_SET ||
weather_info.sunlight == SUN_DARK )
return TRUE;*/

return FALSE;
}
USA #2
Chances are ch->in_room is null. Check out the code that's setting ch->in_room in your character loading routines.

Also, what's with the following?
1387 send_to_char ( ch->in_room->name, ch );

Why are you sending "ch" to "ch"?

Edit:
Duhhhhh... umm... never mind. That will teach me to post when I am on sleep and food deprivation. :/ I'm so used to my new format of send_to_char where the destination comes first, and the text second, that when I saw "ch" in second position I figured you were sending ch. Ah well. :)
Amended on Tue 24 Feb 2004 08:35 PM by David Haley
#3
thats sending the rooms title (a string) to the char.
Australia Forum Administrator #4
When you get to that point in gdb, try printing out all the things on the line in error. The line is:

1387 send_to_char ( ch->in_room->name, ch );


So, I would do this:

p ch
p ch->in_room
p ch->in_room->name

Now if one of those turns out to be zero, or some other nonsense, you have found the reason for the crash. Why it is bad, you would need to find out.