BlockHorizons / BlockPets

An advanced pets plugin for PocketMine-MP
Apache License 2.0
93 stars 61 forks source link

Pets crash the server #176

Closed DenielWorld closed 2 years ago

DenielWorld commented 6 years ago

If multiple people have a pet for at least 5 minutes, the server crashes.

ericsimard52 commented 5 years ago

I think this would more then likely be related to https://github.com/BlockHorizons/BlockPets/issues/147

DenielWorld commented 5 years ago

That is resolved now, but now pets crash a player when he kills one.

ericsimard52 commented 5 years ago

I notice that too. When you reenter the game pet is back full health.

DenielWorld commented 5 years ago

I might be able to get a log, but I'd need your help.

ericsimard52 commented 5 years ago

What do you need?

On Sat, Jan 5, 2019 at 6:37 PM DenielW notifications@github.com wrote:

I might be able to get a log, but I'd need your help.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BlockHorizons/BlockPets/issues/176#issuecomment-451704952, or mute the thread https://github.com/notifications/unsubscribe-auth/ATJCWaML42rDFw7umxYZfTtYQeAwZm59ks5vAUU2gaJpZM4Yxssw .

ericsimard52 commented 5 years ago

It does not cause a crash dump with me, but it crashes before the pet die with the following backtrace:

[Server thread/CRITICAL]: Error: "Call to a member function getServer() on null" (EXCEPTION) in "src/pocketmine/event/entity/EntityDamageByEntityEvent" at line 72 [19:10:00] [Server thread/DEBUG]: #0 src/pocketmine/entity/Living(568): pocketmine\event\entity\EntityDamageByEntityEvent->getDamager() [19:10:00] [Server thread/DEBUG]: #1 BlockPets/src/BlockHorizons/BlockPets/pets/BasePet(337): pocketmine\entity\Living->attack(pocketmine\event\entity\EntityDamageByEntityEvent object) [19:10:00] [Server thread/DEBUG]: #2 BlockPets/src/BlockHorizons/BlockPets/pets/IrasciblePet(72): BlockHorizons\BlockPets\pets\BasePet->attack(pocketmine\event\entity\EntityDamageByEntityEvent object) [19:10:00] [Server thread/DEBUG]: #3 src/pocketmine/Player(2521): BlockHorizons\BlockPets\pets\IrasciblePet->attack(pocketmine\event\entity\EntityDamageByEntityEvent object) [19:10:00] [Server thread/DEBUG]: #4 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(139): pocketmine\Player->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object) [19:10:00] [Server thread/DEBUG]: #5 src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket(155): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object) [19:10:00] [Server thread/DEBUG]: #6 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(99): pocketmine\network\mcpe\protocol\InventoryTransactionPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object) [19:10:00] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/protocol/BatchPacket(114): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object) [19:10:00] [Server thread/DEBUG]: #8 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(99): pocketmine\network\mcpe\protocol\BatchPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object) [19:10:00] [Server thread/DEBUG]: #9 src/pocketmine/Player(3061): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object) [19:10:00] [Server thread/DEBUG]: #10 src/pocketmine/network/mcpe/RakLibInterface(162): pocketmine\Player->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object) [19:10:00] [Server thread/DEBUG]: #11 vendor/pocketmine/raklib/src/server/ServerHandler(98): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 192.168.0.10 49029, raklib\protocol\EncapsulatedPacket object, integer 0) [19:10:00] [Server thread/DEBUG]: #12 src/pocketmine/network/mcpe/RakLibInterface(102): raklib\server\ServerHandler->handlePacket() [19:10:00] [Server thread/DEBUG]: #13 src/pocketmine/network/mcpe/RakLibInterface(92): pocketmine\network\mcpe\RakLibInterface->process() [19:10:00] [Server thread/DEBUG]: #14 vendor/pocketmine/snooze/src/SleeperHandler(120): pocketmine\network\mcpe\RakLibInterface->pocketmine\network\mcpe{closure}() [19:10:00] [Server thread/DEBUG]: #15 vendor/pocketmine/snooze/src/SleeperHandler(82): pocketmine\snooze\SleeperHandler->processNotifications() [19:10:00] [Server thread/DEBUG]: #16 src/pocketmine/Server(2278): pocketmine\snooze\SleeperHandler->sleepUntil(double 1546737000.6685) [19:10:00] [Server thread/DEBUG]: #17 src/pocketmine/Server(2139): pocketmine\Server->tickProcessor() [19:10:00] [Server thread/DEBUG]: #18 src/pocketmine/Server(1715): pocketmine\Server->start() [19:10:00] [Server thread/DEBUG]: #19 src/pocketmine/PocketMine(249): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /home/papa/PMMP/, string /home/papa/PMMP/plugins/) [19:10:00] [Server thread/DEBUG]: #20 /home/papa/PMMP/PocketMine-MP.phar(1): require(string phar:///home/papa/PMMP/PocketMine-MP.phar/src/pocketmine/PocketMine.php)

DenielWorld commented 5 years ago

I need someone on my server to kill a pet to see the crashdump

ericsimard52 commented 5 years ago

Got the crash dump, the above error happen when a player attempted to kill my pet, I think it crashed before the pet died and only caused an error with no crashdump. This time, I spawned multiple spider creature and got them to kill my pet. It created a crashdump this time, seems to be the same error. error.log

ericsimard52 commented 5 years ago

The crash happens after BasePet->attack calls parent::attack($source) I got the debug to tell me the pet health before calling parent::attack, everytime pet's health was at 2 just before the crash.

DenielWorld commented 5 years ago

So is there a possible fix?

ericsimard52 commented 5 years ago

I'm pretty sure there is, I will ask a little patience though, the 2 regular are a little short on time for this, I just started contributing to it.

ericsimard52 commented 5 years ago

A work around for now is to edit config.yml under plugin_data/BlockPets and set Invulnerable-Pets: true

ericsimard52 commented 5 years ago

I have been digging trying to find the exact place where this crash happened, I learned a lot, but I still haven't figured out exactly where it happens. Although it looks like the server crash when the pets die, there is a lot happening between death and crash. I attempted to pinpoint the problematic line by using return statement and following function calls The pets gets kill, the BasePet->onDeath executes. onDeath will not cause a crash until the $newPet = $loader->clonePet($this); execute. Inside clonePet, we will call loader->createPet. Inside of this function if I return $entity before $this->playerPets[$player->getLower....] the server does not crash. It does not make much sense to me, hopefully it will to someone else. If someone has any pointer I will do the work.

ericsimard52 commented 5 years ago

When returning entity before updating playerPets array does not cause a server crash, but also does not respawn the pet. Attempt to toggle the pet afterward results with a crash with the following error:

[Server thread/CRITICAL]: TypeError: "Argument 1 passed to BlockHorizons\BlockPets\commands\BaseCommand::sendWarning() must implement interface pocketmine\command\CommandSender, string given, called in /home/papa/PMMP/plugins/BlockPets/src/BlockHorizons/BlockPets/commands/TogglePetCommand.php on line 92" (EXCEPTION) in "BlockPets/src/BlockHorizons/BlockPets/commands/BaseCommand" at line 43 Mon_Jan_7-16.19.53-CST_2019.log Looking at the logs, you can see it was going to show the warning that I do not have a pet by that name, but I am to log out of the server and back in, the pet is alive.

UPDATE! After my pet died, I was looking at it and wondering what to look for next, and it turns out wait a few seconds and your pet comes back. So it seems that not running: $this->playerPets[$player->getLower....] in loader->createPet fixes the issue.

Update! But with the above modification, togglepet is broken and crash with the above error

ericsimard52 commented 5 years ago

Ok, the crash happen $player->getLowerCaseName() Looks like $player is properly set Update: Replacing it with $player->getName() seems to work. Pet dies, respawn after a few seconds.

ericsimard52 commented 5 years ago

There is issue coming from case on petOwner name and petname. After changing the above in createPet, if fixed the pet dying, but I was unable to togglepet after that. in loader->getPetByName I have to remove the strtolower and getLowCaseName for toggle to work, but this broke pet death again. For myself right now I made a second copy of getPetByName to support toggle. Also after those mods, for some reason my pets would not move when being ridden, I change my petOwner name to lowercase and fixed the later. So I have achieved stability to ride, toggle, tp pet and pets death. But not in a acceptable code yet. Any reason why we have to play this much with name capitalization? Would it not be better to stay case sensitive? I first thought to lowercase before we write to database, but that can cause an issue when comparing petOwner to Player name when the later has a capital in it.

Ifera commented 2 years ago

Should be fixed with the latest update. If not then please do make a new issue.