char_from_room crash

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 1 month ago #6770 by JTP
char_from_room crash was created by JTP
Seems i every few weeks gets a crash with this message:
May 27 04:25:44 :: SYSERR: NULL character or NOWHERE in handler.c,
char_from_room

Anyone who can tell me how to fix it ?


handler.c

/* move a player out of a room */
void char_from_room(struct char_data *ch)
{
  struct char_data *temp;

  if (ch == NULL || IN_ROOM(ch) == NOWHERE) {
    log("SYSERR: NULL character or NOWHERE in %s, char_from_room", __FILE__);
    exit(1);
  }

  if (FIGHTING(ch) != NULL)
    stop_fighting(ch);

  char_from_furniture(ch);

  if (GET_EQ(ch, WEAR_LIGHT) != NULL)
    if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT)
      if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2))	/* Light is ON */
	world[IN_ROOM(ch)].light--;

  REMOVE_FROM_LIST(ch, world[IN_ROOM(ch)].people, next_in_room);
  IN_ROOM(ch) = NOWHERE;
  ch->next_in_room = NULL;
}


Here is the second place in handler.c with char_from_room
  /* Whipe character from the memory of hunters and other intelligent NPCs... */
  for (temp = character_list; temp; temp = temp->next) {
    /* PCs can't use MEMORY, and don't use HUNTING() */
    if (!IS_NPC(temp))
      continue;
    /* If "temp" is hunting our extracted char, stop the hunt. */
    if (HUNTING(temp) == ch)
      HUNTING(temp) = NULL;
    /* If "temp" has allocated memory data and our ch is a PC, forget the 
     * extracted character (if he/she is remembered) */  
    if (!IS_NPC(ch) && GET_POS(ch) == POS_DEAD && MEMORY(temp))
      forget(temp, ch); /* forget() is safe to use without a check. */
  }

  char_from_room(ch);

  if (IS_NPC(ch)) {
    if (GET_MOB_RNUM(ch) != NOTHING)	/* prototyped */
      mob_index[GET_MOB_RNUM(ch)].number--;
    clearMemory(ch);

    if (SCRIPT(ch))
      extract_script(ch, MOB_TRIGGER);

    if (SCRIPT_MEM(ch))
      extract_script_mem(SCRIPT_MEM(ch));
  } else {
    save_char(ch);
    Crash_delete_crashfile(ch);
  }

  /* If there's a descriptor, they're in the menu now. */
  if (IS_NPC(ch) || !ch->desc)
    free_char(ch);
}

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

More
1 year 1 month ago #6771 by thomas
Replied by thomas on topic char_from_room crash
Actually, this is a bad way to exit the program. I suggest you switch exit(1); to abort();. This way you should get a core dump with a stack trace, showing where the call is coming from and which value is the culprit.

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 1 month ago #6772 by JTP
Replied by JTP on topic char_from_room crash
The exit(1); is stock, nothing i made.

So nothing Else in the char_from_room springs to your attention as causing it ?

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

More
1 year 1 month ago #6773 by thomas
Replied by thomas on topic char_from_room crash
Oh, you mustn't think I think YOU wrote that - it's a holdover from old circle code.

And no, the rest of the code around that point looks fine to me. It's not this part of the code that's at fault, even if it is the part that is failing.
Somewhere, you are sending a char_data to this function when already in nowhere (ie. "in menu/dead") or you are passing in a NULL char_data.
However, knowing that makes it no more possible for us to help you. We need more info. And abort() dumps core (unless on an ARM system), so it will supply the needed core dump for you to supply us with backtraces, info, etc.
exit(1) just lets the autorun script know something didn't go well.

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

Time to create page: 1.023 seconds