Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, DotBot, Bing, Majestic-12

Members: 0
Guests: 23
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Crash due to argument not tra...
Forum Rules | Mark all | Recent Posts

Crash due to argument not transferring within code - Solved
< Newer Topic :: Older Topic > I'm confused here...

Pages:<< prev 1 next >>
Post is unread #1 May 9, 2011, 8:57 pm   Last edited May 9, 2011, 8:57 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

After a long absence of asking questions, have a crash that is stumping me because I don't see any reason for it to not work. Basically, when given an argument, it's completely ignored by do_brandish and nulled out, which causes a crash. It wasn't doing this about a week ago, and there's been no change in the interp.c or act_obj.c since then.
#0  do_brandish (ch=0x9465c30, argument=0xbfffed80 "") at act_obj.c:3512
3512            if(!IS_NPC(vch) && xIS_SET(vch->act, PLR_WIZINVIS) && vch->pcdata->wizinvis >= LEVEL_IMMORTAL)
(gdb) bt
#0  do_brandish (ch=0x9465c30, argument=0xbfffed80 "") at act_obj.c:3512
#1  0x0815b75d in interpret (ch=0x9465c30, argument=0xbfffed7d "orb")
    at interp.c:574
#2  0x080f2de0 in game_loop () at comm.c:1333
#3  0x080f689d in main (argc=Cannot access memory at address 0x0
) at comm.c:859

Looking at this, it seems to lose the argument from interp.c:574 to do_brandish. Anyone have an idea why this might be?

Feel free to ask me questions, kinda late and not thinking quite straight, so may be missing significant information...maybe...

Cheers,
Aurin
       
Post is unread #2 May 9, 2011, 10:58 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

If it happens again, when you get to the point of doing the backtrace, try:

print vch

See what value is stored there.
       
Post is unread #3 May 10, 2011, 10:33 am
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

(gdb) print vch
$1 = (CHAR_DATA *) 0x0

Looks like vch is null. do_brandish isn't placing the argument as vch. Or, maybe it is, since it's not transferring the argument "orb" from interp.c:574 to act_obj.c:3512.
do_brandish looks like this, so I don't see why it wouldn't take the argument:
void do_brandish(CHAR_DATA *ch, char *argument)
{
  CHAR_DATA              *vch;
  CHAR_DATA              *vch_next;
  OBJ_DATA               *staff;
  ch_ret                  retcode;
  int                     sn;
  char                    arg[MIL];

I did go through and simply call "vch = ch;" so it wouldn't crash, but it's still losing the argument.
       
Post is unread #4 May 10, 2011, 11:56 am
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

argument isn't null, it's just blank. That shouldn't cause a crash. If a command arg is blank, there should be code in that function to handle that case.
       
Post is unread #5 May 10, 2011, 12:12 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

There is code to handle a blank argument. However, the argument's not supposed to be blank. Look back at the first post, the argument loses "orb" from interp.c to act_obj.c. Granted "orb" wouldn't be handled as valid, but it's simply ignored in act_obj.c so that it can't be handled in the first place. So, like I said, the argument is being lost in the code transferring from interp.c to act_obj.c.

I also see that the pointer(?) for the argument is being changed from argument=0xbfffed7d "orb" in interp.c to argument=0xbfffed80 "" in act_obj.c. So, doesn't look like it's even passing correctly.
       
Post is unread #6 May 10, 2011, 12:44 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Can you post your copy of the entire do_brandish function? I've looked through the copy in SmaugFUSS and it doesn't even do anything with the argument.

The only way vch can be NULL in the unmodified function is if you're brandishing a staff in a room with no occupants. That should be impossible since you're an occupant, so it should always at the very least check yourself.
       
Post is unread #7 May 10, 2011, 12:56 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Like Samson said, brandish doesn't do anything with the argument. So this isn't why it's crashing.

I don't think vch has to do with argument. Isn't vch part of a list of characters in the room?
       
Post is unread #8 May 10, 2011, 1:28 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Yes, vch is part of a list of characters in the room. It should never be possible to hit a NULL on that because the person executing the command is also in that room. Unless for some reason the brandish command caused him to get ejected from the original room while the loop was processing.
       
Post is unread #9 May 10, 2011, 1:54 pm   Last edited May 10, 2011, 2:23 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

void do_brandish(CHAR_DATA *ch, char *argument)
{
  CHAR_DATA              *vch;
  CHAR_DATA              *vch_next;
  OBJ_DATA               *staff;
  ch_ret                  retcode;
  int                     sn;
  char                    arg[MIL]; // Aurin
  
  argument = one_argument(argument, arg); // Aurin
  
  if((staff = get_eq_char(ch, WEAR_HOLD)) == NULL)
  {
    send_to_char("You hold nothing in your hand.\r\n", ch);
    return;
  }

  if(staff->item_type != ITEM_STAFF)
  {
    send_to_char("You can brandish only with a staff.\r\n", ch);
    return;
  }

  if((sn = staff->value[3]) < 0 || sn >= top_sn || skill_table[sn]->spell_fun == NULL)
  {
    bug("Do_brandish: bad sn %d.", sn);
    return;
  }

  WAIT_STATE(ch, 2 * PULSE_VIOLENCE);

// Changed the below as it was targeting everyone in the room through a for loop, now it targets
// self, argument or if neither and fighting, who_fighting(ch) - Aurin
  if(staff->value[2] > 0)
  {
    if(!oprog_use_trigger(ch, staff, NULL, NULL, NULL))
    {
      act(AT_MAGIC, "$n brandishes $p.", ch, staff, NULL, TO_ROOM);
      act(AT_MAGIC, "You brandish $p.", ch, staff, NULL, TO_CHAR);
    }
    
	if(arg[0] == '\0' || argument == "")
	  vch = ch;
	else
	  vch = get_char_room(ch, arg);
	
    if(!vch)
	  vch = ch;
	
	if(!IS_NPC(vch) && xIS_SET(vch->act, PLR_WIZINVIS) && vch->pcdata->wizinvis >= LEVEL_IMMORTAL)
      return;
	  
    retcode = obj_cast_spell(staff->value[3], staff->value[0], ch, vch, NULL);
    if(retcode == rCHAR_DIED || retcode == rBOTH_DIED)
    {
      bug("%s", "do_brandish: char died");
      return;
    }
  }

  if(--staff->value[2] <= 0)
  {
    act(AT_MAGIC, "$p blazes bright and vanishes from $n's hands!", ch, staff, NULL, TO_ROOM);
    act(AT_MAGIC, "$p blazes bright and is gone!", ch, staff, NULL, TO_CHAR);
    if(staff->serial == cur_obj)
      global_objcode = rOBJ_USED;
    extract_obj(staff);
  }

  return;
}

Yes, I changed it because it would hit everyone in the room, even mobs--which is kinda silly. But, after my change, it worked just fine and would take the argument and place it as the vch. Now, a week later, it stopped working--and there have been copyovers and whatnot that had nothing to do with the function.

Edited out the below, as I was just using that to see what the values were:
	ch_printf(ch, "vch is %s and ch is %s and argument is %s\r\n", vch->name, ch->name, argument);
       
Post is unread #10 May 10, 2011, 2:01 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Don't know why interp is losing the arg, that's a bit deeper. If we focus on the crash issue first...

Going by the logic, the ifcheck is crashing because vch is null. But you have a check for that, where if vch is null then it gets set to ch. But it doesn't crash on the ch_printf line, so does that print out at all? Probably not because the buffer isn't flushed in time, but what about in gdb? Try info local in frame 0
       
Post is unread #11 May 10, 2011, 2:19 pm   Last edited May 10, 2011, 2:24 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

No, it doesn't print out the ch_printf line prior to the crash.
(gdb) info local in frame 0
vch = (CHAR_DATA *) 0x0
staff = (OBJ_DATA *) 0x93effe8
retcode = Variable "retcode" is not available.


*Note: the if(!vch) check was added to stop the crashes, remove this check and it crashes like it's been doing. The point is, I can't use the argument to set vch. So, it's not really surprising that vch is null, as it can't be set by the argument in the first place.

Posting down here too, as I made an edit above:
Edited out the below, as I was just using that to see what the values were:
	ch_printf(ch, "vch is %s and ch is %s and argument is %s\r\n", vch->name, ch->name, argument);
       
Post is unread #12 May 10, 2011, 5:04 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

From the look of things you don't even need to do the one_argument stuff and then use arg in the get_char_room call. Try removing the one_argument call, and change any references of arg into argument. Then see what happens.
       
Post is unread #13 May 10, 2011, 5:43 pm   Last edited May 10, 2011, 5:45 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Thanks Samson, that solved my issue (along with adding in a vch == NULL check--this is what's returned if ch is not present from get_char_room). heh
       
Pages:<< prev 1 next >>