Page 1 of 1

Small Crash

Posted: Wed Dec 14, 2016 9:04 pm
by Gangrenous
I do not think there is major, but still interesting. It could be a change I made, always better to have two sets of eyes on it. This was a simple battle, although I did have "protect owner" and a pet out. I think I was just testing some combat against one of the treant style mobs in Antonica.

Code: Select all

    function=function@entry=0x754310 <ZoneServer::GetSpawnByID(unsigned int)::__FUNCTION__> "GetSpawnByID", line=line@entry=3424) at ../common/Mutex.cpp:91
#6  0x00000000006c1e94 in ZoneServer::GetSpawnByID (this=0x86cd7f0,
    id=id@entry=22388) at zoneserver.cpp:3424
#7  0x00000000005ed6ae in NPC::GetOwner (this=<optimized out>) at NPC.cpp:861
#8  0x000000000052a763 in Entity::AddHate (this=0x25, attacker=0x0, hate=69)
    at Combat.cpp:959
#9  0x000000000052a6dd in Entity::AddHate (this=0x25, attacker=0x0, hate=69)
    at Combat.cpp:965
#10 0x000000000052a773 in Entity::AddHate (this=0x25, attacker=0x0, hate=69)
---Type <return> to continue, or q <return> to quit---
    at Combat.cpp:959
#11 0x000000000052a6dd in Entity::AddHate (this=0x25, attacker=0x0, hate=69)
    at Combat.cpp:965
#12 0x000000000052a773 in Entity::AddHate (this=0x25, attacker=0x0, hate=69)
    at Combat.cpp:959
Now if you look it really all goes back to these lines in combat.cpp

Code: Select all

	// If pet is adding hate add some to the pets owner as well
	if (attacker->IsNPC() && ((NPC*)attacker)->IsPet())
		AddHate(((NPC*)attacker)->GetOwner(), 5);

	// If player and player has a pet and protect master is set add hate to the pet
	if (IsPlayer() && HasPet() && (((Player*)this)->GetInfoStruct()->pet_behavior & 1)) {
		// If we have a combat pet add hate to it
		if (((Player*)this)->GetPet())
			AddHate(((Player*)this)->GetPet(), 1);
		if (((Player*)this)->GetCharmedPet())
			AddHate(((Player*)this)->GetCharmedPet(), 1);
	}
It really should not had been hitting line 958 at all, the attack was not an NPC, because the NPC never had a pet. It should had passed into 962 for sure, that is protect master and a player with a pet. All in all, it had a mutex read lock here...

Code: Select all

Spawn* ZoneServer::GetSpawnByID(int32 id) {
	Spawn* ret = 0;
	MSpawnList.readlock(__FUNCTION__, __LINE__);
	if (spawn_list.count(id) > 0)
		ret = spawn_list[id];
	MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
	return ret;
}
I may have time to jump on the test server in the morning and see if it crashes there.

Re: Small Crash

Posted: Wed Dec 14, 2016 9:16 pm
by Jabantiz
Pets are NPC's so it is likely the players pet that is hitting that code. What is interesting is attacker = 0x0 that doesn't seem right to me, like it is null, but if it was null it should crash a lot sooner then that.

Re: Small Crash

Posted: Thu Dec 15, 2016 6:14 am
by Gangrenous
I am going to dig further in and see if I can locate it this morning.