Login
User Name:

Password:



Register

Forgot your password?
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
SWRFUSS 1.4
Author: Various
Submitted by: Samson
Users Online
There are currently no members online.

Members: 0
Guests: 25
Stats
Files
Topics
Posts
Members
Newest Member
488
3,788
19,631
595
Khonsu

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » Codebases » SmaugFUSS » segfault connecting to link d...
Forum Rules | Mark all | Recent Posts

segfault connecting to link dead
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 12, 2018 5:34 pm   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
using 1.9b, compiling on cygwin..

there seems to be an error when connecting to link dead characters

I was getting errors about bool always being false in comm.c and changed check_reconnect to int instead of bool, which got rid of error....

but would segfault when connecting to link dead.. I changed it back to bool and removed -Werror from makefile so it would compile, and even then.. still segfaults on connecting to link-dead.

connecting to an already connected player works fine.. but if they are link-dead... it crashes after putting in password.


anyone have a fix?

Post is unread #2 Mar 13, 2018 1:25 am   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 

joeyfogas said:

using 1.9b, compiling on cygwin..

there seems to be an error when connecting to link dead characters

I was getting errors about bool always being false in comm.c and changed check_reconnect to int instead of bool, which got rid of error....

but would segfault when connecting to link dead.. I changed it back to bool and removed -Werror from makefile so it would compile, and even then.. still segfaults on connecting to link-dead.

connecting to an already connected player works fine.. but if they are link-dead... it crashes after putting in password.


anyone have a fix?


Did you by chance implement any other changes associated with this? I seem to recall there was a fix floating around on Github before that would cause this exact behavior. Had to do with calling check_reconnect( ) more than once.

That is, if you have something like this, then that's the problem:

   if( check_reconnect( d, argument, FALSE ) == BERR )
       return;
 
   if( check_reconnect( d, argument, FALSE ) )
    {
       fOld = TRUE;
    }


Calling it twice in a row is a Bad Thing. Someone once proposed a fix on Github without adequately testing it, which might be how you picked it up.

If you can verify that this is what you have going on, and possibly show what you have in this section of code for your particular base, I am pretty sure myself or others here can help you fix it.

Post is unread #3 Mar 13, 2018 2:21 am   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
if( check_reconnect( d, argument, FALSE ) == BERR )
      return;



if( check_reconnect( d, argument, FALSE ) )
   {
      fOld = TRUE;
   }
   else
   {
      if( sysdata.wizlock && !IS_IMMORTAL( ch ) )
      {
         write_to_buffer( d, "The game is wizlocked. Only immortals can connect now.\r\n", 0 );
         write_to_buffer( d, "Please try back later.\r\n", 0 );
         close_socket( d, FALSE );
         return;
      }


I do, indeed have it called twice in a row... So I should comment out one? if so, which one?

Post is unread #4 Mar 13, 2018 2:32 am   Last edited Mar 13, 2018 2:36 am by joeyfogas
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
 }

   ch = d->character;
   if( check_bans( ch, BAN_SITE ) )
   {
      write_to_buffer( d, "Your site has been banned from this Mud.\r\n", 0 );
      close_socket( d, FALSE );
      return;
   }

   if( fOld )
   {
      if( check_bans( ch, BAN_CLASS ) )
      {
         write_to_buffer( d, "Your class has been banned from this Mud.\r\n", 0 );
         close_socket( d, FALSE );
         return;
      }
      if( check_bans( ch, BAN_RACE ) )
      {
         write_to_buffer( d, "Your race has been banned from this Mud.\r\n", 0 );
         close_socket( d, FALSE );
         return;
      }
   }

   if( xIS_SET( ch->act, PLR_DENY ) )
   {
      log_printf_plus( LOG_COMM, sysdata.log_level, "Denying access to %s@%s.", argument, d->host );
      if( d->newstate != 0 )
      {
         write_to_buffer( d, "That name is already taken.  Please choose another: ", 0 );
         d->connected = CON_GET_NAME;
         d->character->desc = NULL;
         free_char( d->character ); /* Big Memory Leak before --Shaddai */
         d->character = NULL;
         return;
      }
      write_to_buffer( d, "You are denied access.\r\n", 0 );
      close_socket( d, FALSE );
      return;
   }

   /*
    *  Make sure the immortal host is from the correct place.
    *  Shaddai
    */
   if( IS_IMMORTAL( ch ) && sysdata.check_imm_host && !check_immortal_domain( ch, d->host ) )
   {
      log_printf_plus( LOG_COMM, sysdata.log_level, "%s's char being hacked from %s.", argument, d->host );
      write_to_buffer( d, "This hacking attempt has been logged.\r\n", 0 );
      close_socket( d, FALSE );
      return;
   }

if( check_reconnect( d, argument, FALSE ) == BERR )
      return;


if( check_reconnect( d, argument, FALSE ) )
   {
      fOld = TRUE;
   }
   else
   {
      if( sysdata.wizlock && !IS_IMMORTAL( ch ) )
      {
         write_to_buffer( d, "The game is wizlocked. Only immortals can connect now.\r\n", 0 );
         write_to_buffer( d, "Please try back later.\r\n", 0 );
         close_socket( d, FALSE );
         return;
      }
   }

   if( fOld )
   {
      if( d->newstate != 0 )
      {
         write_to_buffer( d, "That name is already taken. Please choose another: ", 0 );
         d->connected = CON_GET_NAME;
         d->character->desc = NULL;
         free_char( d->character ); /* Big Memory Leak before --Shaddai */
         d->character = NULL;
         return;
      }

      /*
       * Old player
       */
      write_to_buffer( d, "Password: ", 0 );
      write_to_buffer( d, (const char *)echo_off_str, 0 );
      d->connected = CON_GET_OLD_PASSWORD;
      return;
   }
   else
   {
      /*
       * if ( !check_parse_name( argument ) )
       * {
       * write_to_buffer( d, "hat name is reserved, please try another.\r\nName: ", 0 );
       * return;
       * }
       */
      if( d->newstate == 0 )
      {
         /*
          * No such player
          */
         write_to_buffer( d, "\r\nNo such player exists.\r\nPlease check your spelling, or type new to start a new player.\r\n\r\nName: ", 0 );
         d->connected = CON_GET_NAME;
         d->character->desc = NULL;
         free_char( d->character ); /* Big Memory Leak before --Shaddai */
         d->character = NULL;
         return;
      }

      snprintf( buf, MAX_STRING_LENGTH, "Did I get that right, %s (Y/N)? ", argument );
      write_to_buffer( d, buf, 0 );
      d->connected = CON_CONFIRM_NEW_NAME;
      return;
   }

Post is unread #5 Mar 13, 2018 3:09 am   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 
joeyfogas said:

if( check_reconnect( d, argument, FALSE ) == BERR )
      return;



if( check_reconnect( d, argument, FALSE ) )
   {
      fOld = TRUE;
   }
   else
   {
      if( sysdata.wizlock && !IS_IMMORTAL( ch ) )
      {
         write_to_buffer( d, "The game is wizlocked. Only immortals can connect now.\r\n", 0 );
         write_to_buffer( d, "Please try back later.\r\n", 0 );
         close_socket( d, FALSE );
         return;
      }


I do, indeed have it called twice in a row... So I should comment out one? if so, which one?


Yep, figured as much. You need to change it back to when it was using another variable to store the result of the first and only function call, rather than having multiple function calls to check the result. Changing it to an integer was never the problem, that's fine, but you need to not eliminate the 'chk' variable.

Something like this:

	chk = check_reconnect( d, argument, FALSE );
	
	if ( chk == BERR )
	    return;
	    
	if ( chk )
	{
	    fOld = TRUE;
	}
	else


The 'chk' variable can be an integer if you've changed check_reconnect( ) to return an integer too, that part of the fix is fine, but you need to do like above and avoid calling the function twice in a row. Does that make sense?

Also note that a similar block appears elsewhere, depending on how old your base code is, and so you might have to change it there as well. I believe for mine it was somewhere in the case CON_GET_OLD_PASSWORD: section. That may or may not apply to your code base, but worth checking.


Post is unread #6 Mar 13, 2018 3:12 am   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
awesome.. let me commit these changes and I'll post an update

Post is unread #7 Mar 13, 2018 3:17 am   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
  Compiling o/comm.o....
comm.c: In function ‘void nanny_get_name(DESCRIPTOR_DATA*, char*)’:
comm.c:1974:11: error: comparison of constant ‘255’ with boolean expression is always false [-Werror=bool-compare]
  if ( chk == BERR )

Post is unread #8 Mar 13, 2018 3:22 am   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
   if( check_playing( d, ch->pcdata->filename, TRUE ) )
      return;

if( check_reconnect( d, ch->pcdata->filename, TRUE ) == BERR )
   {
      if( d->character && d->character->desc )
         d->character->desc = NULL;
      close_socket( d, FALSE );
      return;
   }
if( check_reconnect( d, ch->pcdata->filename, TRUE ) )
      return;




is this the similar code you were talking about?

Post is unread #9 Mar 13, 2018 3:35 am   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 

joeyfogas said:

   if( check_playing( d, ch->pcdata->filename, TRUE ) )
      return;

if( check_reconnect( d, ch->pcdata->filename, TRUE ) == BERR )
   {
      if( d->character && d->character->desc )
         d->character->desc = NULL;
      close_socket( d, FALSE );
      return;
   }
if( check_reconnect( d, ch->pcdata->filename, TRUE ) )
      return;




is this the similar code you were talking about?


Yep!

Post is unread #10 Mar 13, 2018 3:35 am   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
I think i need to sleep... lol


got it to stop crashing but now I see my linkdead self when logging back in lol

Post is unread #11 Mar 13, 2018 3:37 am   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 

joeyfogas said:

  Compiling o/comm.o....
comm.c: In function ‘void nanny_get_name(DESCRIPTOR_DATA*, char*)’:
comm.c:1974:11: error: comparison of constant ‘255’ with boolean expression is always false [-Werror=bool-compare]
  if ( chk == BERR )


To rid yourself of this, do what the fix said about changing the return value of check_reconnect( ) to an integer instead of a bool. Just make sure when you define 'chk' that you define it as an integer too, not a bool.

Post is unread #12 Mar 13, 2018 3:53 am   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
ok after the first change, it still segfaulted.. then I found the similar section, I believe, in the con_get_password and changed it as such...


chk = check_reconnect( d, argument, FALSE );
//if( check_reconnect( d, ch->pcdata->filename, TRUE ) == BERR )
if ( chk == BERR )
   {
      if( d->character && d->character->desc )
         d->character->desc = NULL;
      close_socket( d, FALSE );
      return;
   }
//if( check_reconnect( d, ch->pcdata->filename, TRUE ) )
if ( chk )
      return;


this finally allowed me to log in after being link dead without crashing, however, this is what I see when logging in


The Parlour of the Immortals
[Exits: none]
+-----------+ You are lounging in a quiet cosy parlour, warmed by a gentle 
|           | magical fire which twinkles happily in a warm fireplace. 
|           | 
|           | 
|           | 
|     @     | 
|           | 
|           | 
|           | 
|           | 
+-----------+ 
Mystical sparkling colors converge here to form arcane runes...
[(Link Dead)] (Immortal) Xander The Magnificent (glowing)


nevermind the formatting... but I can see myself.. link dead

Post is unread #13 Mar 13, 2018 4:02 am   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
here is the comm.c file

this may prove easier to assist..


thanks again for all your help... I apparently don't know what I am doing

Post is unread #14 Mar 13, 2018 4:19 am   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
ok i got it!

i compared it to the 1.9.1 code

this is what i did wrong

chk = check_reconnect( d, ch->pcdata->filename, TRUE );
//chk = check_reconnect( d, argument, FALSE );
//if( check_reconnect( d, ch->pcdata->filename, TRUE ) == BERR )
if ( chk == BERR )
   {
      if( d->character && d->character->desc )
         d->character->desc = NULL;
      close_socket( d, FALSE );
      return;
   }
//if( check_reconnect( d, ch->pcdata->filename, TRUE ) )
if ( chk )
      return;



Post is unread #15 Mar 13, 2018 4:24 am   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
JoinedAug 28, 2016

 
someone should swap the 1.9.2 comm.c file with the 1.9.1 file and do the fix correctly :(

Post is unread #16 Mar 13, 2018 12:12 pm   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 

joeyfogas said:

someone should swap the 1.9.2 comm.c file with the 1.9.1 file and do the fix correctly :(


Yeah it's a little confusing with the two different places, TRUE vs. FALSE and what not. Glad you got it sorted out though! :alien:


Pages:<< prev 1 next >>