Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Bing, Yandex, DotBot, Google

Members: 0
Guests: 12
Stats
Files
Topics
Posts
Members
Newest Member
481
3,735
19,370
618
Micheal64X
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » General Discussions » Crash in mprog_speech_trigger
Forum Rules | Mark all | Recent Posts

Crash in mprog_speech_trigger
< Newer Topic :: Older Topic > Um....

Pages:<< prev 1 next >>
* #1 Aug 4, 2005, 8:41 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

The code:

void mprog_speech_trigger( char *txt, char_data * actor )
{
   char_data *vmob;
   list<char_data*>::iterator ich;
   room_index *room = actor->in_room;

   log_string( "HERE I AM" );
   for( ich = room->people.begin(); ich != room->people.end(); )
   {
      vmob = (*ich);
      ich++;

      log_printf( "THIS IS ROOM: %d", room->vnum );
      log_printf( "MY NAME IS: %s", vmob->name );
      log_printf( "TEXT: %s", txt );
      if( vmob->isnpc(  ) && HAS_PROG( vmob->pIndexData, SPEECH_PROG ) )
      {
         if( actor->isnpc(  ) && actor->pIndexData == vmob->pIndexData )
            continue;
         mprog_wordlist_check( txt, vmob, actor, NULL, NULL, SPEECH_PROG );
      }
   }
}


The mobprog:

>speech_prog p I am ready
if mobinroom(2868) == 1
mpecho The statue of Meia glows with a blue aura and animates.
say You are not yet ready to receive your reward and leave.
say Defeat the Guardian first.
mpecho The aura around the statue disappears and it is still again.
else
mpecho The statue of Meia glows with a blue aura and animates.
say You are now ready to leave the safety of Gwyn al'Fer.
say Fare thee well in your adventures in Alsherok.
give runed $n
say Take this as a reward and may it serve you well.
mpecho The aura around the statue disappears and it is still again.
mpecho You are drawn through a magical portal which opens before you.
mpopenpassage 2926 7035 4
mpforce $n up
mpclosepassage 2926 4
endif


What I caught in debugging:

Thu Aug 4, 2005 8:22:21 PM PDT :: Loading player data for Samson (37K)
Thu Aug 4, 2005 8:22:21 PM PDT :: Samson [samson.arthmoor.com] has connected.
Thu Aug 4, 2005 8:22:24 PM PDT :: MCCP support detected for Samson.
Thu Aug 4, 2005 8:22:24 PM PDT :: MSP support detected for Samson.
Thu Aug 4, 2005 8:22:24 PM PDT :: Samson returns from beyond the void.
Thu Aug 4, 2005 8:22:27 PM PDT :: HERE I AM
Thu Aug 4, 2005 8:22:27 PM PDT :: THIS IS ROOM: 2926
Thu Aug 4, 2005 8:22:27 PM PDT :: MY NAME IS: statue meia carving abecedarium
Thu Aug 4, 2005 8:22:27 PM PDT :: TEXT: i am ready
Thu Aug 4, 2005 8:22:27 PM PDT :: HERE I AM
Thu Aug 4, 2005 8:22:27 PM PDT :: THIS IS ROOM: 2926
Thu Aug 4, 2005 8:22:27 PM PDT :: MY NAME IS: statue meia carving abecedarium
Thu Aug 4, 2005 8:22:27 PM PDT :: TEXT: You are now ready to leave the safety of Gwyn al'Fer.
Thu Aug 4, 2005 8:22:27 PM PDT :: THIS IS ROOM: 2926
Thu Aug 4, 2005 8:22:27 PM PDT :: MY NAME IS: Samson
Thu Aug 4, 2005 8:22:27 PM PDT :: TEXT: You are now ready to leave the safety of Gwyn al'Fer.
Thu Aug 4, 2005 8:22:27 PM PDT :: HERE I AM
Thu Aug 4, 2005 8:22:27 PM PDT :: THIS IS ROOM: 2926
Thu Aug 4, 2005 8:22:27 PM PDT :: MY NAME IS: statue meia carving abecedarium
Thu Aug 4, 2005 8:22:27 PM PDT :: TEXT: Fare thee well in your adventures in Alsherok.
Thu Aug 4, 2005 8:22:27 PM PDT :: THIS IS ROOM: 2926
Thu Aug 4, 2005 8:22:27 PM PDT :: MY NAME IS: Samson
Thu Aug 4, 2005 8:22:27 PM PDT :: TEXT: Fare thee well in your adventures in Alsherok.
Thu Aug 4, 2005 8:22:27 PM PDT :: HERE I AM
Thu Aug 4, 2005 8:22:27 PM PDT :: THIS IS ROOM: 2926
Thu Aug 4, 2005 8:22:27 PM PDT :: MY NAME IS: statue meia carving abecedarium
Thu Aug 4, 2005 8:22:27 PM PDT :: TEXT: Take this as a reward and may it serve you well.
Thu Aug 4, 2005 8:22:27 PM PDT :: THIS IS ROOM: 2926
Thu Aug 4, 2005 8:22:27 PM PDT :: MY NAME IS: Samson
Thu Aug 4, 2005 8:22:27 PM PDT :: TEXT: Take this as a reward and may it serve you well.
Thu Aug 4, 2005 8:22:27 PM PDT :: THIS IS ROOM: 2926
==27643== 
==27643== Invalid read of size 1
==27643==    at 0x1D172F: vfprintf (in /lib/libc-2.3.5.so)
==27643==    by 0x1EF76E: vsnprintf (in /lib/libc-2.3.5.so)
==27643==    by 0x8153C86: log_printf(char const*, ...) (db.c:2560)
==27643==    by 0x81AAF93: mprog_speech_trigger(char*, char_data*) (mud_prog.c:3500)
==27643==    by 0x80D8EC0: do_say (act_comm.c:500)
==27643==    by 0x814E6D7: interpret(char_data*, char*) (commands.c:1427)
==27643==    by 0x81486AB: process_input() (comm.c:824)
==27643==    by 0x814873A: game_loop() (comm.c:890)
==27643==    by 0x8148A24: main (comm.c:1258)
==27643==  Address 0x6 is not stack'd, malloc'd or (recently) free'd
==27643== 
==27643== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- 


There are only two characters in room 2926. Myself and the mob Meia. This is a consistent crasher in this one function apparently. I have no idea why, and indications are that the room's list of people picked up something it wasn't supposed to as it got to the last say command in the prog, even though of course no other characters entered or left the room.
       
Post is unread #2 Aug 5, 2005, 2:39 am
Go to the top of the page
Go to the bottom of the page

Gatz
Apprentice
GroupMembers
Posts60
JoinedJul 25, 2005

The one thing I noticed is that the name changed when the $n token was used. It might be good to examine what the code does when it gets passed '$n' or even test it to see if other prog variables screw around with it, namely doing $n then using $N just to see what would happen, if anything.
       
Post is unread #3 Aug 6, 2005, 8:48 pm   Last edited Aug 6, 2005, 8:49 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

Well, Gatz, it doesn't have anything to do with the variables that I can see. Somehow any speech_prog which has a command that causes the actor to leave the room, either by movement or by transfer, crashes the game. Since this turned into something that wasn't going to be easy to track down and I can't have the game crashing on demand, I modified the trigger as such:

void mprog_speech_trigger( char *txt, char_data * actor )
{
   char_data *vmob;
   list<char_data*>::iterator ich;
   room_index *room = actor->in_room;

   log_string( "HERE I AM" );
   for( ich = room->people.begin(); ich != room->people.end(); )
   {
      vmob = (*ich);
      ich++;

      if( actor == vmob )
         continue;
      if( actor->isnpc(  ) && actor->pIndexData == vmob->pIndexData )
         continue;

      // Band-aid fix to stop unknown crash
      if( actor->in_room != vmob->in_room )
         break;

      log_printf( "THIS IS ROOM: %d", actor->in_room->vnum );
      log_printf( "MY NAME IS: %s", vmob->name );
      log_printf( "TEXT: %s", txt );
      if( vmob->isnpc(  ) && HAS_PROG( vmob->pIndexData, SPEECH_PROG ) )
      {
         mprog_wordlist_check( txt, vmob, actor, NULL, NULL, SPEECH_PROG );
      }
   }
}


With that change, the progs work, and I don't seem to be getting any residual memory corruption or leakage from it. The only thing I wonder about is if this would be an acceptable permanent fix for the problem.
       
Post is unread #4 Aug 7, 2005, 12:30 am   Last edited Aug 7, 2005, 12:57 am by Gatz
Go to the top of the page
Go to the bottom of the page

Gatz
Apprentice
GroupMembers
Posts60
JoinedJul 25, 2005

I kept looking over your code over and over, and even examined the release AFKMUD code (even though I know your's has been coverted to C++) and something kept bugging me and that was this particular piece of code:
for( ich = room->people.begin(); ich != room->people.end(); )

I don't know if you switched around mprog_wordlist_check() but in the AFKMUD version. However, I came up with a theory (excuse my ignorance on some of C++ my knowledge is a bit rusty). That being room->people.end() is being called in the beginning before the player is moved, however when the player is moved the room->people.end() isn't updated and therefore will consider the player still there. If that is the case then would a another possible fix be:

      if( vmob->isnpc(  ) && HAS_PROG( vmob->pIndexData, SPEECH_PROG ) )
      {
         mprog_wordlist_check( txt, vmob, actor, NULL, NULL, SPEECH_PROG );
         break;
      }

That having a problem that if more than one mobile has the same speech trigger in a room, it'll only fire one. Another idea to fix it would be to update room->people.end() manually.
Those are just some thoughts, again my C++ is rusty so I hope you excuse me if I totally fell off base.

[Edit: I just also noticed that in the beginning a quick check like:
if(!vmob)
break;
Because the thing could be checking a NULL vmod aswell, because it isn't in the room.]

       
Pages:<< prev 1 next >>