Access violation with morphed characters

Posted by Nick Gammon on Fri 25 Nov 2005 08:48 PM — 4 posts, 16,884 views.

Australia Forum Administrator #0
Samson,

There seems to be a problem with using morph in SMAUG. I was playing with polymorph recently, and created a new polymorph, like this:


morphcreate fish


Then I used it on myself:


c polymorph fish


However if I then do something like:


goto some-player-name


MUD crash!

It appears from using gdb that the problem is here:


      while( ( *point = *i ) != '\0' )
         ++point, ++i;


This is line 3006 of comm.c, inside act_string function.

The reason for the crash is "i" is NULL.

The reason i is NULL is this define:


#define MORPHNAME(ch)   ((ch->morph&&ch->morph->morph)? \
                         ch->morph->morph->short_desc: \
                         IS_NPC(ch) ? ch->short_descr : ch->name)


In my example, I hadn't set up morph->short_desc and thus it was NULL.

I suggest a change of either:

  • Making the define fallback to the name if the short description is NULL; or
  • Make morphcreate supply a default short name (eg. the morph name).

Amended on Fri 25 Nov 2005 08:50 PM by Nick Gammon
USA #1
http://forums.smaugfuss.org/index.php?a=topic&t=495

Interesting results from trying to fix it. Don't know why but that MORPHNAME macro/function is not enough by itself to fix this problem. After changing it to a function so I could see it in backtrace, I was baffled to see that the code path was never executed ( unless it was optimized away? ). So the i variable was always NULL even when it clearly should not have been.

The second listed change in that fix was ultimately what allowed it to work, but I've gone ahead and included them both in the distro just in case.

[EDIT - 11 March 2008] - The Smaug FUSS site is now http://www.smaugmuds.org/
Amended on Tue 11 Mar 2008 03:21 AM by Nick Gammon
Australia Forum Administrator #2
I would have thought that the line:


#define NAME(ch) ( IS_NPC(ch) ? ch->short_descr : ch->name )


would need to read:



#define NAME(ch) ( IS_NPC(ch) && ch->short_descr ? ch->short_descr : ch->name )

USA #3
You may well be right about that. Can't hurt in any case. I'm just wondering why it is the MORPHNAME one was never touched.