05 Oct, 2013, Michael wrote in the 1st comment:
Votes: 0
I have an SWR based MUD that I started with using SWRFUSS 1.0. I have applied all of the bug fixes from the SmaugMuds.org SWR forum list so hopefully I am up-to-date and didn't miss any. However, I am having a weird issue I can't seem to figure out or track down exactly why it's causing a crash. I have not done anything to the way corpses are created. I've also compared my code to SWRFUSS 1.2 and 1.3 code and it all looks the same.

Here is the situation:

Mob has nocorpse flag.
Kill mob, MUD crashes.

GDB returns this information:

(gdb) bt
#0 0x00000000005227bc in damage (ch=0x1998a80, victim=0x0, dam=439, dt=1006) at fight.c:2032
#1 0x00000000005201e6 in one_hit (ch=0x1998a80, victim=0x17c3760, dt=1006) at fight.c:1402
#2 0x000000000051d496 in multi_hit (ch=0x1998a80, victim=0x17c3760, dt=-1) at fight.c:501
#3 0x0000000000526d5f in do_kill (ch=0x1998a80, argument=0x7fff196682d5 "toodan") at fight.c:3413
#4 0x000000000054df8b in interpret (ch=0x1998a80, argument=0x7fff196682d5 "toodan") at interp.c:412
#5 0x00000000004e1e83 in game_loop () at comm.c:730
#6 0x00000000004e0d1f in main (argc=6, argv=0x7fff19668828) at comm.c:304
(gdb)


(gdb) list
2027
2028 set_cur_char( victim );
2029 new_corpse = raw_kill( ch, victim );
2030 victim = NULL;
2031
2032 if( ch->tempnum != INT_MIN && !IS_NPC( ch ) && loot && new_corpse && new_corpse->item_type == ITEM_CORPSE_NPC
2033 && new_corpse->in_room == ch->in_room && can_see_obj( ch, new_corpse ) && ch->position > POS_SLEEPING )
2034 {
2035 /*
2036 * Autogold by Scryn 8/12
2037 */
2038 if( IS_SET( ch->act, PLR_AUTOGOLD ) && !loot_coins_from_corpse( ch, new_corpse ) )
2039 return rBOTH_DIED;
2040
2041 if( new_corpse && !obj_extracted( new_corpse ) && new_corpse->in_room == ch->in_room
2042 && ch->position > POS_SLEEPING && can_see_obj( ch, new_corpse ) )
2043 {
2044 if( IS_SET( ch->act, PLR_AUTOLOOT ) )
2045 do_get( ch, "all corpse" );
2046 else
(gdb)


*Toodan is just the name of the mob.

Before I posted this, I went back to check other corpse affecting flags for mobs, ie. NOKILL, and it worked properly.

Any help would be appreciated. Thanks.
05 Oct, 2013, Davenge wrote in the 2nd comment:
Votes: 0
Whats the actual error? Segmentation fault? I'd make sure the raw_kill method is explicitly returning NULL if the mob is set no_corpse.
06 Oct, 2013, Natilena wrote in the 3rd comment:
Votes: 0
At a quick glance the only thing that jumps out at me is this:

#0 0x00000000005227bc in damage (ch=0x1998a80, victim=0x0, dam=439, dt=1006) at fight.c:2032

You don't seem to have a victim pointer anymore. The other lines are this: victim=0x17c3760.
06 Oct, 2013, plamzi wrote in the 4th comment:
Votes: 0
Natilena said:
At a quick glance the only thing that jumps out at me is this:

#0 0x00000000005227bc in damage (ch=0x1998a80, victim=0x0, dam=439, dt=1006) at fight.c:2032

You don't seem to have a victim pointer anymore. The other lines are this: victim=0x17c3760.


That's probably the cause. Go to 'frame 1' and 'l' to figure out why your victim pointer becomes NULL. Maybe you shouldn't even reach do_damage in this case…
06 Oct, 2013, Sharmair wrote in the 5th comment:
Votes: 0
About the only thing in the line that crashed that could cause it, is new_corpse being a bad (and not NULL) pointer.
Taking a look at the smaugfuss 1.3 code in the raw_kill function, it does seem this can happen, as the corpse_to_return
variable is not initialized, and is just returned in the case where no corpse is created. I would change the line in raw_kill
(near the top of the function) from:
OBJ_DATA *corpse_to_return;

to:
OBJ_DATA *corpse_to_return = NULL;



As to the victim issue, I would be concerned if victim was NOT NULL at this point. Victim is NULL as it was set so in
line 2030 (line 5 listed in the OP).
06 Oct, 2013, Michael wrote in the 6th comment:
Votes: 0
Initially I looked through the other versions of SWR to see if I could see any differences between my code and the newer SWRFUSS codes. I didn't notice anything different in the way corpses are created or how damaging a mob took place. I did find some changes in the SWFotE code that used an integer called nocorpse and it was set to TRUE if the mob had the nocorpse flag. This integer was then used in an ifcheck for checking whether or not a player would autoloot the corpse or look in the corpse. This solved the issue, but I am not sure if its safe enough to trust.

Sharmair's simple fix seems to be the safest way to prevent a crash with a nocorpse flag. I have confirmed that it works.
0.0/6