Welcome to the Builder Academy

Question Game crashing

More
08 Apr 2023 12:38 - 08 Apr 2023 12:39 #10302 by Nero
Game crashing was created by Nero
For some reason this week I am having issues with the MUD consistently crashing.
I ran game in debug mode and when it crashed again this was the result (attached screenshot)

The only real issue I could find was in db.c I did not have the  if (ch->player_specials) check for  free(ch->player_specials);
Would that be the reason why its crashing? It's the only thing I can was missing.
I corrected it and game seems to be running smooth so far for the last few hours but wanted to make sure I am reading the results of this correct and not missing anything else.
Attachments:
Last edit: 08 Apr 2023 12:39 by Nero.

Please Log in or Create an account to join the conversation.

More
08 Apr 2023 21:08 #10303 by thomas
Replied by thomas on topic Game crashing
Yes, this is highly likely to be the problem. Mobs, for instance, don't have a player_specials structure (it is NULL) and if you free() i anyway, you will be calling free(NULL) which is a segfault.
The following user(s) said Thank You: Nero

Please Log in or Create an account to join the conversation.

More
11 Apr 2023 04:36 #10305 by Nero
Replied by Nero on topic Game crashing
I am not sure why but the game is still crashing. Here is a full screenshot of backtrace
 
Attachments:

Please Log in or Create an account to join the conversation.

More
11 Apr 2023 20:52 #10309 by thomas
Replied by thomas on topic Game crashing
Ok, I've tried doing this exact thing on a new copy of tba and it does not crash for me - but then again, the code does not look like yours:
Code:
oid free_char(struct char_data *ch) { int i; struct alias_data *a; if (ch->player_specials != NULL && ch->player_specials != &dummy_mob) { while ((a = GET_ALIASES(ch)) != NULL) { GET_ALIASES(ch) = (GET_ALIASES(ch))->next; free_alias(a); } if (ch->player_specials->poofin) free(ch->player_specials->poofin); if (ch->player_specials->poofout) free(ch->player_specials->poofout); if (ch->player_specials->saved.completed_quests) free(ch->player_specials->saved.completed_quests); if (GET_HOST(ch)) free(GET_HOST(ch)); if (IS_NPC(ch)) log("SYSERR: Mob %s (#%d) had player_specials allocated!", GET_NAME(ch), GET_MOB_VNUM(ch)); }
As you see, base tba does not try to free the player_specials struct.
If you insist on doing that, at least add
Code:
ch->player_specials = NULL;
after freeing it.

Please Log in or Create an account to join the conversation.

More
12 Apr 2023 00:28 #10310 by Nero
Replied by Nero on topic Game crashing
I think I have it hopefully
comparing mine to TBA code it actually looks like if (ch->player_specials)
free(ch->player_specials);

is pushed down below if (!IS_NPC(ch) || (IS_NPC(ch) && GET_MOB_RNUM(ch) == NOBODY)) {
so far today it seems to be running smooth with no crashes and no errors popping up in debug mode like it was before. Fingers crossed.

Please Log in or Create an account to join the conversation.

More
26 Apr 2023 10:45 #10322 by Nero
Replied by Nero on topic Game crashing
Hi Thomas,

For some reason I am still continuing to have issues with the game crashing
I dug deeper into GDB but I still can't make heads or tails of what the actual issue is.
It continues to act like there is an error in db.c specifically with the free_char

The attached screenshot seems to reference a character that doesn't exist in a room that also does not exist in the game.

You mentioned making the specials = NULL?
So should I just remove the if check and replace it with that?
Code:
/* release memory allocated for a char struct */ void free_char(struct char_data *ch) {   int i;   struct alias_data *a;   if (ch->player_specials != NULL && ch->player_specials != &dummy_mob) {     while ((a = GET_ALIASES(ch)) != NULL) {       GET_ALIASES(ch) = (GET_ALIASES(ch))->next;       free_alias(a);     }     if (ch->player_specials->poofin)       free(ch->player_specials->poofin);     if (ch->player_specials->poofout)       free(ch->player_specials->poofout);     if (ch->player_specials->saved.completed_quests)       free(ch->player_specials->saved.completed_quests);     if (GET_HOST(ch))       free(GET_HOST(ch));     if (IS_NPC(ch))       log("SYSERR: Mob %s (#%d) had player_specials allocated!", GET_NAME(ch), GET_MOB_VNUM(ch));   }   if (!IS_NPC(ch) || (IS_NPC(ch) && GET_MOB_RNUM(ch) == NOBODY)) {     /* if this is a player, or a non-prototyped non-player, free all */     if (GET_NAME(ch))       free(GET_NAME(ch));     if (ch->player.title)       free(ch->player.title);     if (ch->player.short_descr)       free(ch->player.short_descr);     if (ch->player.long_descr)       free(ch->player.long_descr);     if (ch->player.description)       free(ch->player.description);     if (ch->player_specials)       free(ch->player_specials);            /* free script proto list */     free_proto_script(ch, MOB_TRIGGER);   } else if ((i = GET_MOB_RNUM(ch)) != NOBODY) {     /* otherwise, free strings only if the string is not pointing at proto */     if (ch->player.name && ch->player.name != mob_proto[i].player.name)       free(ch->player.name);     if (ch->player.title && ch->player.title != mob_proto[i].player.title)       free(ch->player.title);     if (ch->player.short_descr && ch->player.short_descr != mob_proto[i].player.short_descr)       free(ch->player.short_descr);     if (ch->player.long_descr && ch->player.long_descr != mob_proto[i].player.long_descr)       free(ch->player.long_descr);     if (ch->player.description && ch->player.description != mob_proto[i].player.description)       free(ch->player.description);     /* free script proto list if it's not the prototype */     if (ch->proto_script && ch->proto_script != mob_proto[i].proto_script)       free_proto_script(ch, MOB_TRIGGER);   }   while (ch->affected)     affect_remove(ch, ch->affected);   /* free any assigned scripts */   if (SCRIPT(ch))     extract_script(ch, MOB_TRIGGER);   /* new version of free_followers take the followers pointer as arg */   free_followers(ch->followers);   if (ch->desc)     ch->desc->character = NULL;   /* find_char helper */   /*   * when free_char is called with a blank character struct, ID is set   * to 0, and has not yet been added to the lookup table.   */   if (GET_ID(ch) != 0)     remove_from_lookup_table(GET_ID(ch));   free(ch); }
 
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.340 seconds