Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Segment Fault Issue

Segment Fault Issue

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Toy   (206 posts)  Bio
Date Sat 04 Dec 2004 10:49 AM (UTC)

Amended on Sat 04 Dec 2004 10:53 AM (UTC) by Toy

Message
So after a nice compile, the game started up just fine. Problem is upon loading a character *Boom*. So I used gdb to track down where the issue is, and this is what i got.

(gdb)
game_loop () at comm.c:621
621 break;
(gdb)
635 if ( d == last_descriptor )
(gdb)
640 update_handler( );
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x004861df in get_char_room (ch=0xa229038, argument=0x239cb0 "someone") at handler.c:1864
warning: Source file is more recent than executable.

1864 if ( can_see( ch, rch )
(gdb)
0x7c90eaf0 in ntdll!LdrDisableThreadCalloutsForDll () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!LdrDisableThreadCalloutsForDll,
which has no line number information.
0x7c9377c1 in ntdll!LdrFindCreateProcessManifest () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!LdrFindCreateProcessManifest,
which has no line number information.
0x7c90390c in ntdll!RtlCheckRegistryKey () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!RtlCheckRegistryKey,
which has no line number information.
0x7c9377f0 in ntdll!LdrFindCreateProcessManifest () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!LdrFindCreateProcessManifest,
which has no line number information.
0x7c90392d in ntdll!RtlCheckRegistryKey () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!RtlCheckRegistryKey,
which has no line number information.
0x7c9377f5 in ntdll!LdrFindCreateProcessManifest () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!LdrFindCreateProcessManifest,
which has no line number information.
15 [main] smaug 3916 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
27214 [main] smaug 3916 open_stackdumpfile: Dumping stack trace to smaug.exe.stackdump

Program exited with code 0305400.
(gdb)

So I checked handler.c at 1864:
/* Find a char in the room. */
CHAR_DATA *get_char_room( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *rch;
    int number, count, vnum;

    number = number_argument( argument, arg );
    	
	if ( !str_cmp( arg, "self" ) )
		return ch;

    if ( get_trust(ch) >= LEVEL_CODER && is_number( arg ) )
		vnum = atoi( arg );
    else
		vnum = -1;

    count  = 0;

    for ( rch = ch->in_room->first_person; rch; rch = rch->next_in_room )
	if ( can_see( ch, rch ) 
	&& (((nifty_is_name( arg, rch->name ) || (IS_NPC(rch) && nifty_is_name( arg, rch->pcdata->title ))) 
	|| (IS_NPC(rch) && vnum == rch->pIndexData->vnum))))
	{
	    if ( number == 0 && !IS_NPC(rch) )
			return rch;
	    else
	    if ( ++count == number )
			return rch;
	}
    	
	if ( vnum != -1 )
		return NULL;

/* If we didn't find an exact match, run through the list of characters
   again looking for prefix matching, ie gu == guard. Added by Narn, Sept/96 */
    count  = 0;

    for ( rch = ch->in_room->first_person; rch; rch = rch->next_in_room )
    {
		if ( !can_see( ch, rch ) || (!nifty_is_name_prefix( arg, rch->name ) 
		&& (IS_NPC(rch) || (!IS_NPC(rch) && !nifty_is_name_prefix( arg, rch->pcdata->title )))))
	    	continue;
	
		if ( number == 0 && !IS_NPC(rch) )
	    	return rch;
		else
		if ( ++count == number )
	    	return rch;
    }
	return NULL;
}


Error line is in bold. I'm guessing there is an issue with bool can_see, but I don't see it. I'll post can_see next.
Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Toy   (206 posts)  Bio
Date Reply #1 on Sat 04 Dec 2004 10:54 AM (UTC)
Message

/* True if char can see victim. */
bool can_see( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( !victim )            /* Gorog - panicked attempt to stop crashes */
       	return FALSE;
    
    if ( victim->position == POS_FIGHTING || victim->position < POS_SLEEPING )
		return TRUE;

    if ( !ch )
    {
      	if ( IS_AFFECTED(victim, AFF_INVISIBLE)
      	||   IS_AFFECTED(victim, AFF_HIDE)
      	||   xIS_SET(victim->act, PLR_WIZINVIS) ) 
			return FALSE;
      	else
			return TRUE;
    }

    if ( ch == victim )
		return TRUE;

    if ( !IS_NPC(victim)
    &&   xIS_SET(victim->act, PLR_WIZINVIS)
    &&   get_trust( ch ) < victim->pcdata->wizinvis )
		return FALSE;

    if ( victim->position == POS_FIGHTING || victim->position < POS_SLEEPING )
		return TRUE;
	
    if ( victim->position == POS_FIGHTING || victim->position < POS_SLEEPING )
		return TRUE;

/* SB */
    if ( IS_NPC(victim)   
    &&   xIS_SET(victim->act, ACT_MOBINVIS)
    &&   get_trust( ch ) < victim->mobinvis )
        return FALSE;

    if ( !IS_NPC(ch) && xIS_SET(ch->act, PLR_HOLYLIGHT) )
		return TRUE;
	
/* The miracle cure for blindness? -- Altrag */
    if ( !IS_AFFECTED(ch, AFF_TRUESIGHT) )
    {
		if ( IS_AFFECTED(ch, AFF_BLIND) )
	  		return FALSE;

		if ( room_is_dark( ch->in_room ) && !IS_AFFECTED(ch, AFF_INFRARED) )
	  		return FALSE;

		if ( IS_AFFECTED(victim, AFF_INVISIBLE) && !IS_AFFECTED(ch, AFF_DETECT_INVIS) )
	  		return FALSE;

		if ( IS_AFFECTED(victim, AFF_HIDE)
		&&   !IS_AFFECTED(ch, AFF_DETECT_HIDDEN)
		&&   !victim->fighting
		&&   ( IS_NPC(ch) ? !IS_NPC(victim) : IS_NPC(victim) ) )
	  		return FALSE;
    }    
    return TRUE;
}


Any thoughts?

Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #2 on Sat 04 Dec 2004 01:30 PM (UTC)
Message
Loading a character? I'm going to say null rch. Can you reproduce that crash, and print ch and rch for me?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Toy   (206 posts)  Bio
Date Reply #3 on Sun 05 Dec 2004 11:40 AM (UTC)
Message
2108 act( AT_ACTION, "$n has entered the game.", ch, NULL, NULL, TO_CANSEE )
;
(gdb)
2110 if ( ch->plr_home != NULL )
(gdb)
2185 if ( ch->pcdata->pet )
(gdb)
2191 do_look( ch, "auto" );
(gdb)
2192 mail_count(ch);
(gdb)
2193 check_loginmsg(ch);
(gdb)
2197 }
(gdb)
game_loop () at comm.c:621
621 break;
(gdb)
635 if ( d == last_descriptor )
(gdb)
640 update_handler( );
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x004861df in get_char_room (ch=0xa229038, argument=0x239cb0 "someone") at handler.c:1864
1864 if ( can_see( ch, rch )
(gdb)
0x7c90eaf0 in ntdll!LdrDisableThreadCalloutsForDll () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!LdrDisableThreadCalloutsForDll,
which has no line number information.
0x7c9377c1 in ntdll!LdrFindCreateProcessManifest () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!LdrFindCreateProcessManifest,
which has no line number information.
0x7c90390c in ntdll!RtlCheckRegistryKey () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!RtlCheckRegistryKey,
which has no line number information.
0x7c9377f0 in ntdll!LdrFindCreateProcessManifest () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!LdrFindCreateProcessManifest,
which has no line number information.
0x7c90392d in ntdll!RtlCheckRegistryKey () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!RtlCheckRegistryKey,
which has no line number information.
0x7c9377f5 in ntdll!LdrFindCreateProcessManifest () from ntdll.dll
(gdb)
Single stepping until exit from function ntdll!LdrFindCreateProcessManifest,
which has no line number information.
6 [main] smaug 2452 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
113065 [main] smaug 2452 open_stackdumpfile: Dumping stack trace to smaug.exe.stackdump

I can repeat the crash as many times as I want. Tried making a newbie, instead of using an old char. Same affect. Everything was fine through nanny until the update handler call.

As for the rest of what you're asking for, I'm not sure what you mean. :(

Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #4 on Sun 05 Dec 2004 11:47 AM (UTC)
Message
It means to just type 'print ch' and 'print rch' in gdb to show the values of the ch and rch variables.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Toy   (206 posts)  Bio
Date Reply #5 on Sun 05 Dec 2004 07:40 PM (UTC)
Message
Program received signal SIGSEGV, Segmentation fault.
0x004861df in get_char_room (ch=0xa229038, argument=0x239cb0 "someone") at handler.c:1864
1864 if ( can_see( ch, rch )
(gdb) print ch
$6 = (CHAR_DATA *) 0xa229038
(gdb) print rch
$7 = (CHAR_DATA *) 0xa229038

this what you're looking for?

Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #6 on Sun 05 Dec 2004 07:57 PM (UTC)
Message
Yeah. Hmm, so neither is null. What is line 1864 of can_see?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Toy   (206 posts)  Bio
Date Reply #7 on Mon 06 Dec 2004 01:34 AM (UTC)
Message
Line 1864 is called to handler.c in get_char_room on the line:

if ( can_see( ch, rch )

as I posted earlier. what's odd though is there's a call to "someone", but there is no word "someone" in handler.c. Could my description macro's be causing it?

/* Description macros. */
#define DISGUISE(ch)            ((!nifty_is_name(ch->name, ch->pcdata->title)) ?   \
								1 : 0)
#define PERS(ch, looker)		( can_see( (looker), (ch) ) ?		\
								( IS_NPC(ch) ? (ch)->short_descr	\
								: ((get_trust(looker) <= LEVEL_IMMORTAL) ? (DISGUISE(ch) ? ch->pcdata->title : (ch)->name ) : (ch)->name)) : ( IS_IMMORTAL(ch) ? "A Great One" : "someone" ))

#define MORPHPERS(ch, looker)   ( can_see( (looker), (ch) ) ?           \
                                (ch)->morph->morph->short_desc       \
                                : "someone" )


Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #8 on Mon 06 Dec 2004 02:19 AM (UTC)
Message
Quote:
Program received signal SIGSEGV, Segmentation fault.
0x004861df in get_char_room (ch=0xa229038, argument=0x239cb0 "someone") at handler.c:1864
warning: Source file is more recent than executable.
Might want to fix that, too, otherwise your gdb running will be out of synch with your actual code.

Also...
Quote:
Program received signal SIGSEGV, Segmentation fault.
0x004861df in get_char_room (ch=0xa229038, argument=0x239cb0 "someone") at handler.c:1864
1864 if ( can_see( ch, rch )
(gdb)
Here, you should type 'bt' to do a backtrace - that'll show you what's dying where. Single stepping after a segfault is useless.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Toy   (206 posts)  Bio
Date Reply #9 on Mon 06 Dec 2004 12:58 PM (UTC)
Message
I made sure to update the .exe. Didn't notice that, but the problem still exists. I I did a bt like suggested:

Program received signal SIGSEGV, Segmentation fault.
0x004861df in get_char_room (ch=0xa229038, argument=0x239cb0 "someone") at handler.c:1864
1864 if ( can_see( ch, rch )
(gdb) bt
#0 0x004861df in get_char_room (ch=0xa229038, argument=0x239cb0 "someone") at handler.c:1864
#1 0x004b8865 in do_mpechoat (ch=0xa229038,
argument=0x23b97c "A burlap sack, some clothes, and a torch are given to you. Use")
at mud_comm.c:477
#2 0x0049b957 in interpret (ch=0xa229038,
argument=0x23b974 "Someone A burlap sack, some clothes, and a torch are given to you. Use")
at interp.c:681
#3 0x004bff12 in mprog_do_command (
cmnd=0x23c281 "mea $n A burlap sack, some clothes, and a torch are given to you. Use",
mob=0xa229038, actor=0xa2685b8, obj=0x0, vo=0x0, rndm=0x0, ignore=0 '\0',
ignore_ors=0 '\0') at mud_prog.c:2362
#4 0x004bfa81 in mprog_driver (
com_list=0xa118a90 "mpoload 123 1\n\rmpoload 367 1\n\rmpoload 113 1\n\rgive sack 0.$n\n\rgi
ve clothes 0.$n\n\rgive torch 0.$n\n\rmea $n A burlap sack, some clothes, and a torch are given
to you. Use\n\rmea $n these items to help you o"..., mob=0xa229038, actor=0xa2685b8,
obj=0x0, vo=0x0, single_step=0 '\0') at mud_prog.c:2059
#5 0x004c02f7 in mprog_wordlist_check (
arg=0xa268f10 "A Great One has entered the game.\n\r", mob=0xa229038, actor=0xa2685b8,
obj=0x0, vo=0x0, type=0) at mud_prog.c:2471
#6 0x005036ef in aggr_update () at update.c:2104
#7 0x005042ff in update_handler () at update.c:2508
#8 0x0045cfb1 in game_loop () at comm.c:640
#9 0x0045c726 in main (argc=1, argv=0xa052020) at comm.c:291
(gdb)

I'm currently looking at everything from the backtrace right now to see if I can find the issue. Anyone notice anything?

Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #10 on Mon 06 Dec 2004 01:17 PM (UTC)
Message
#0 0x004861df in get_char_room (ch=0xa229038, argument=0x239cb0 "someone") at handler.c:1864


That looks wrong. It's trying to find a character in the room by the name of "someone". I would think that would make rch null, but that may not be the problem.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Toy   (206 posts)  Bio
Date Reply #11 on Mon 06 Dec 2004 01:50 PM (UTC)
Message
Ok... I just found a weird issue. I tried looking into my area files for that mob program it was calling to and removed it. Now I can log in just fine. Gonna play around witn mob programs some and see if that's the issue.

Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #12 on Mon 06 Dec 2004 07:53 PM (UTC)
Message
Looks like your mob couldn't see the player in question. Strange that it would crash, though. Look at how $n evaluates to 'Someone'.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


38,526 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.