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 ➜ Seg Fault in Comm.c in Void Act (GDB output)

Seg Fault in Comm.c in Void Act (GDB output)

This subject is now closed.     Refresh page


Posted by Syriac   (46 posts)  Bio
Date Sun 07 Jun 2009 03:53 PM (UTC)
Message
I'm having an issue in my MUD where players sometimes will inadvertantly crash us by killing a mob. It is random, and it takes time for it to happen but it seems to happen without fail eventually.

I booted up the mud in GDB and got this feedback.

Program received signal SIGSEGV, Segmentation fault.
0x000000000045e4c5 in act (AType=1045,
format=0x20000000d <Address 0x20000000d out of bounds>, ch=0xd63e50,
arg1=0x0, arg2=0x0, type=0) at comm.c:3167
3167 if ( !format || format[0] == '\0' )

has this happened to anyone else? how was it resolved? help please!
[Go to top]
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #1 on Sun 07 Jun 2009 06:00 PM (UTC)
Message
Two topics aren't needed for this.

Can you show us the full backtrace?

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

Posted by Syriac   (46 posts)  Bio
Date Reply #2 on Sun 07 Jun 2009 08:54 PM (UTC)
Message
apologies for that, i couldn't see a delete option. what do you mean by back trace? this was the entire message provided by gdb.
Top

Posted by Syriac   (46 posts)  Bio
Date Reply #3 on Sun 07 Jun 2009 09:51 PM (UTC)
Message
void act( sh_int AType, const char *format, CHAR_DATA *ch, const void
*arg1, const void *arg2, int type )
{
char *txt;
const char *str;
CHAR_DATA *to;
CHAR_DATA *vch = (CHAR_DATA *)arg2;
#define ACTF_NONE 0
#define ACTF_TXT BV00
#define ACTF_CH BV01
#define ACTF_OBJ BV02

OBJ_DATA *obj1 = (OBJ_DATA *)arg1;
OBJ_DATA *obj2 = (OBJ_DATA *)arg2;
int flags1 = ACTF_NONE, flags2 = ACTF_NONE;

/*
* Discard null and zero-length messages.
*/
if ( !format || format[0] == '\0' )
return;

if ( !ch )
{
bug( "Act: null ch. (%s)", format );
return;
}

// Do some proper type checking here.. Sort of. We base it on the $* params.
// This is kinda lame really, but I suppose in some weird sense it beats having
// to pass like 8 different NULL parameters every time we need to call act()..
for (str = format; *str; ++str)
{
if (*str == '$')
{
if (!*++str)
break;
switch(*str)
{
default:
bug( "Act: bad code %c for format %s.", *str, format );
break;

case 't':
flags1 |= ACTF_TXT;
obj1 = NULL;
break;

case 'T':
case 'd':
flags2 |= ACTF_TXT;
vch = NULL;
obj2 = NULL;
break;

case 'n': case 'e': case 'm': case 's': case 'q':
break;

case 'N': case 'E': case 'M': case 'S': case 'Q':
flags2 |= ACTF_CH;
obj2 = NULL;
break;

case 'p':
flags1 |= ACTF_OBJ;
break;

case 'P':
flags2 |= ACTF_OBJ;
vch = NULL;
break;
}
}
}


if (flags1 != ACTF_NONE && flags1 != ACTF_TXT && flags1 != ACTF_CH && flags1 != ACTF_OBJ)
{
bug("Act: arg1 has more than one type in format %s. Setting all NULL.", format);
obj1 = NULL;
}

if (flags2 != ACTF_NONE && flags2 != ACTF_TXT && flags2 != ACTF_CH && flags2 != ACTF_OBJ)
{
bug("Act: arg2 has more than one type in format %s. Setting all NULL.", format);
vch = NULL;
obj2 = NULL;
}

if ( !ch->in_room )
to = NULL;
else if ( type == TO_CHAR )
to = ch;
else
to = ch->in_room->first_person;

/*
* ACT_SECRETIVE handling
*/
if ( IS_NPC(ch) && xIS_SET(ch->act, ACT_SECRETIVE) && type != TO_CHAR )
return;

if ( type == TO_VICT )
{
if ( !vch )
{
bug( "Act: null vch with TO_VICT." );
bug( "%s (%s)", ch->name, format );
return;
}
if ( !vch->in_room )
{
bug( "Act: vch in NULL room!" );
bug( "%s -> %s (%s)", ch->name, vch->name, format );
return;
}
to = vch;
/* to = vch->in_room->first_person;*/
}

if ( MOBtrigger && type != TO_CHAR && type != TO_VICT && to )
{
OBJ_DATA *to_obj;

txt = act_string(format, NULL, ch, arg1, arg2, STRING_IMM);
if ( HAS_PROG(to->in_room, ACT_PROG) )
rprog_act_trigger(txt, to->in_room, ch, (OBJ_DATA *)arg1, (void *)arg2);
for ( to_obj = to->in_room->first_content; to_obj;
to_obj = to_obj->next_content )
if ( HAS_PROG(to_obj->pIndexData, ACT_PROG) )
oprog_act_trigger(txt, to_obj, ch, (OBJ_DATA *)arg1, (void *)arg2);
}

/* Anyone feel like telling me the point of looping through the whole
room when we're only sending to one char anyways..? -- Alty */
for ( ; to; to = (type == TO_CHAR || type == TO_VICT)
? NULL : to->next_in_room )
{
if ((!to->desc
&& ( IS_NPC(to) && !HAS_PROG(to->pIndexData, ACT_PROG) ))
|| !IS_AWAKE(to) )
continue;

if ( type == TO_CHAR && to != ch )
continue;
if ( type == TO_VICT && ( to != vch || to == ch ) )
continue;
if ( type == TO_ROOM && to == ch )
continue;
if ( type == TO_NOTVICT && (to == ch || to == vch) )
continue;
if ( type == TO_CANSEE && ( to == ch ||
(!IS_NPC(ch) && (xIS_SET(ch->act, PLR_WIZINVIS)
&& (get_trust(to) < (ch->pcdata ? ch->pcdata->wizinvis : 0) ) ) ) ) )
continue;

if ( IS_IMMORTAL(to) )
txt = act_string (format, to, ch, arg1, arg2, STRING_IMM);
else
txt = act_string (format, to, ch, arg1, arg2, STRING_NONE);

if (to->desc)
{
if ( AType == AT_COLORIZE )
{
if ( txt[0] == '&' )
send_to_char_color( txt, to );
else
{
set_char_color(AT_MAGIC, to );
write_to_buffer( to->desc, txt, strlen(txt) );
}
}
else {
set_char_color(AType, to);
write_to_buffer( to->desc, txt, strlen(txt) );
}
}
if (MOBtrigger)
{
/* Note: use original string, not string with ANSI. -- Alty */
mprog_act_trigger( txt, to, ch, (OBJ_DATA *)arg1, (void *)arg2 );
}
}
MOBtrigger = TRUE;
return;
}
Top

Posted by Conner   USA  (381 posts)  Bio
Date Reply #4 on Sun 07 Jun 2009 09:56 PM (UTC)
Message
No, that's not the entire output from GDB, it's the top of the stack, from there the next step is to type bt and hit enter to see the backtrace.. mandatory reading (at least a cursory overview) for a would be coder is the guide Nick Gammon has written for using GDB, you can ever so conveniently find a copy right here at these very forums, just click on over to http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3653 and take a gander. ;)

-=Conner=-
--
Come test your mettle in the Land of Legends at telnet://tcdbbs.zapto.org:4000
or, for a little family oriented medieval fun, come join us at The Castle's Dungeon BBS at telnet://tcdbbs.zapto.org
or, if you just want information about either, check our web page at http://tcdbbs.zapto.org
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Sun 07 Jun 2009 09:58 PM (UTC)
Message
Let's continue in one spot, in the other thread:

http://www.gammon.com.au/forum/?id=9492

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Conner   USA  (381 posts)  Bio
Date Reply #6 on Sun 07 Jun 2009 10:01 PM (UTC)
Message
Works for me, your response over there looked spot on too, at least to me.

-=Conner=-
--
Come test your mettle in the Land of Legends at telnet://tcdbbs.zapto.org:4000
or, for a little family oriented medieval fun, come join us at The Castle's Dungeon BBS at telnet://tcdbbs.zapto.org
or, if you just want information about either, check our web page at http://tcdbbs.zapto.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.


22,639 views.

This subject is now 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.