Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
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
Users Online
CommonCrawl, Majestic-12, Yahoo!, Google

Members: 0
Guests: 7
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Coding » Reroll snippet causing core d...
Forum Rules | Mark all | Recent Posts

Reroll snippet causing core dump
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 29, 2012, 6:37 pm
Go to the top of the page
Go to the bottom of the page

thatjdguy
Fledgling
GroupMembers
Posts14
JoinedJul 2, 2012

Running SmaugFUSS 1.9 and installed Samson's stat reroller. When creating a new char everything goes smoothly until it comes to the stat roller. If the first set of stats is accepted the player goes through to the newbie area and everything is great. If the player rejects the first set of stats and attempts to roll again the MUD crashes.

I'm new to using gdb but here's what I've been able to determine thusfar.

(gdb) bt
#0  0x081758a4 in name_stamp_stats (ch=0x1000) at handler.c:4279
#1  0x0812b6f1 in nanny (d=0xa700b00, argument=0xbfb9e63c "n") at comm.c:2716
#2  0x08125c7b in game_loop () at comm.c:863
#3  0x08124f56 in main (argc=2, argv=0xbfb9eb24) at comm.c:533

(gdb) list
4274	}
4275	*/
4276	
4277	void name_stamp_stats( CHAR_DATA *ch )
4278	{
4279	     ch->perm_str = 6 + dice( 2,6 );
4280	     ch->perm_dex = 6 + dice( 2,6 );
4281	     ch->perm_wis = 6 + dice( 2,6 );
4282	     ch->perm_int = 6 + dice( 2,6 );
4283	     ch->perm_con = 6 + dice( 2,6 );


So the problem appears to be the ch->perm_str line, but how would I possibly go about fixing that? Everything looks correct to me.
       
Post is unread #2 Sep 29, 2012, 6:53 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Could you provide the code at comm.c:2716 (and surrounding relevant code) as well as the rest of void name_stamp_stats?

Off the cuff, looks like garbage data sent over as ch, and hence the crash. Never seen "ch=0x1000" before. :shrug:
       
Post is unread #3 Sep 29, 2012, 7:22 pm
Go to the top of the page
Go to the bottom of the page

thatjdguy
Fledgling
GroupMembers
Posts14
JoinedJul 2, 2012

      case CON_ROLL_STATS:
	 switch( argument[0] )
	 {
	    case 'y': case 'Y':
	       write_to_buffer( d, "Would you like RIP, ANSI, or no graphic/color support? (R/A/N)?", 0 );
	       d->connected = CON_GET_WANT_RIPANSI;
	    break;

	    case 'n': case 'N':
	       name_stamp_stats( ch );

	    snprintf( buf, MAX_STRING_LENGTH, "\r\nStr: %d  Int: %d  Wis: %d  Dex: %d  Con: %d  Cha: %d  Lck: %d\r\nKeep? (Y/N)",
	       ch->perm_str, ch->perm_int, ch->perm_wis, ch->perm_dex, ch->perm_con, 
	       ch->perm_cha, ch->perm_lck );
	       write_to_buffer( d, buf, 0 );
	    return;
	    default: write_to_buffer( d, "Yes or No? ", 0 );
	    return;
         }
      break;


Line 2716 is the name_stamp_stats call for the case 'n' in comm.c

void name_stamp_stats( CHAR_DATA *ch )
{
     ch->perm_str = 6 + dice( 2,6 );
     ch->perm_dex = 6 + dice( 2,6 );
     ch->perm_wis = 6 + dice( 2,6 );
     ch->perm_int = 6 + dice( 2,6 );
     ch->perm_con = 6 + dice( 2,6 );
     ch->perm_cha = 6 + dice( 2,6 );
     ch->perm_lck = 6 + dice( 2,6 );
     
     ch->perm_str	+= race_table[ch->race]->str_plus;
     ch->perm_int	+= race_table[ch->race]->int_plus;
     ch->perm_wis	+= race_table[ch->race]->wis_plus;
     ch->perm_dex	+= race_table[ch->race]->dex_plus;
     ch->perm_con	+= race_table[ch->race]->con_plus;
     ch->perm_cha	+= race_table[ch->race]->cha_plus; 
     ch->perm_lck	+= race_table[ch->race]->lck_plus;
}
       
Post is unread #4 Sep 29, 2012, 7:30 pm   Last edited Sep 29, 2012, 7:44 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

nevermind...I was kinda stupid...doesn't matter here and can't delete post.. heh hmm

Okay, try this:
      case CON_ROLL_STATS:
	 switch( argument[0] )
	 {
            CHAR_DATA *ch;
            ch = d->character;

	    case 'y': case 'Y':
	       write_to_buffer( d, "Would you like RIP, ANSI, or no graphic/color support? (R/A/N)?", 0 );
	       d->connected = CON_GET_WANT_RIPANSI;
	    break;

	    case 'n': case 'N':
	       name_stamp_stats( ch );

	    snprintf( buf, MAX_STRING_LENGTH, "\r\nStr: %d  Int: %d  Wis: %d  Dex: %d  Con: %d  Cha: %d  Lck: %d\r\nKeep? (Y/N)",
	       ch->perm_str, ch->perm_int, ch->perm_wis, ch->perm_dex, ch->perm_con, 
	       ch->perm_cha, ch->perm_lck );
	       write_to_buffer( d, buf, 0 );
	    return;
	    default: write_to_buffer( d, "Yes or No? ", 0 );
	    return;
         }
      break;


Just defining ch here...not sure if it will help any, but never know.
       
Post is unread #5 Sep 29, 2012, 7:56 pm
Go to the top of the page
Go to the bottom of the page

thatjdguy
Fledgling
GroupMembers
Posts14
JoinedJul 2, 2012

ch is defined at the top of void nanny, but I did add the line for ch = d->character. Got another dump with the exact same info in the bt and list.
       
Post is unread #6 Sep 29, 2012, 8:19 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

yeah, I'm at a loss as well. :( maybe Remcon or someone more knowledgeable can speak up...
       
Post is unread #7 Sep 29, 2012, 8:26 pm
Go to the top of the page
Go to the bottom of the page

thatjdguy
Fledgling
GroupMembers
Posts14
JoinedJul 2, 2012

I remember years ago I got it working with Smaug 1.4, but that was just compile errors. Thanks for giving it a try. I'm not nearly advanced enough to figure this one out.
       
Post is unread #8 Sep 29, 2012, 8:29 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

well, in 1.9 is setup differently than how you appear to have it setup. each of the cases you have are separate functions in smaugfuss1.9 fresh download. :shrug:
       
Post is unread #9 Sep 29, 2012, 10:21 pm
Go to the top of the page
Go to the bottom of the page

thatjdguy
Fledgling
GroupMembers
Posts14
JoinedJul 2, 2012

My head obviously isn't in it tonight, was overlooking a compile error
comm.c:2716:25: warning: ‘ch’ may be used uninitialized in this function


Not knowledgeable enough in coding to know how it would be uninitialized when it's declared at the top of nanny
       
Post is unread #10 Sep 29, 2012, 10:32 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

uninitialized means it wasn't set...adding in what I said to add in should have fixed that, though (ch = d->character).

So, try this: Go to the top of the nanny function where ch is declared and make sure that it looks something like this:
CHAR_DATA    *ch;
ch = d->character;


If it is, then d->character is NULL (okay, we know it's not NULL as ch != 0x0, but it's definitely garbage data as I mentioned before) and you might want to look through and figure out why the value may not be carrying through. or, try declaring in each case CON_GET_* and see if that makes a difference...not saying it will, but you can at least be assured that it should be getting the most up-to-date information possible.
       
Post is unread #11 Sep 29, 2012, 10:51 pm
Go to the top of the page
Go to the bottom of the page

thatjdguy
Fledgling
GroupMembers
Posts14
JoinedJul 2, 2012

Working beautifully now. Thank you!
       
Post is unread #12 Sep 29, 2012, 11:25 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Great! Glad to be of help! :)
       
Pages:<< prev 1 next >>