pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.27k stars 1.54k forks source link

Server crash when player teleport to ungenerated chunk of another world #4486

Closed leolee3914 closed 3 years ago

leolee3914 commented 3 years ago

Issue description

Steps to reproduce the issue

  1. teleport to ungenerated chunk of another world by plugin

OS and versions

[17:55:09.305] [Server thread/INFO]: This server is running PocketMine-MP
[17:55:09.305] [Server thread/INFO]: Server version: 4.0.0-BETA3 (git hash: 9bc07a9cc0ed1b653d961846a059049319c918d1)
[17:55:09.305] [Server thread/INFO]: Compatible Minecraft version: 1.17.30 (protocol version: 465)
[17:55:09.305] [Server thread/INFO]: PHP version: 8.0.10
[17:55:09.306] [Server thread/INFO]: PHP JIT: disabled
[17:55:09.306] [Server thread/INFO]: Operating system: win

Plugins

Crashdump, backtrace or other files

plugin:

<?php

declare(strict_types=1);

namespace test;

use pocketmine\event\Listener;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\plugin\PluginBase;
use pocketmine\world\Position;
use function assert;

class test extends PluginBase implements Listener{

    function onEnable () : void {
        $this->getServer()->getPluginManager()->registerEvents($this, $this);
    }

    function tap ( PlayerInteractEvent $e ) {
        $p = $e->getPlayer();

        $targetWorld = $this->getServer()->getWorldManager()->getWorldByName('target');
        assert($targetWorld !== $p->getPosition()->getWorld());

        $p->teleport(new Position(50000, 128, 50000, $targetWorld));
    }

}

console:

[17:55:01.221] [Server thread/INFO]: Loading server configuration
[17:55:01.244] [Server thread/INFO]: Selected English (eng) as the base language
[17:55:01.247] [Server thread/INFO]: Starting Minecraft: Bedrock Edition server version v1.17.30
[17:55:01.252] [Server thread/INFO]: Online mode is enabled. The server will verify that players are authenticated to Xbox Live.
[17:55:01.348] [Server thread/INFO]: This server is running PocketMine-MP version 4.0.0-BETA3
[17:55:01.348] [Server thread/INFO]: PocketMine-MP is distributed under the LGPL License
[17:55:01.597] [Server thread/INFO]: Loading resource packs...
[17:55:01.619] [Server thread/INFO]: Loading DevTools v1.15.0+dev
[17:55:01.628] [Server thread/INFO]: Enabling DevTools v1.15.0+dev
[17:55:01.629] [Server thread/INFO]: Loading test v1.0.0
[17:55:01.631] [Server thread/INFO]: [DevTools] Registered folder plugin loader
[17:55:01.951] [Server thread/INFO]: Preparing world "target"
[17:55:01.956] [Server thread/NOTICE]: Spawn terrain for world "target" is being generated in the background
[17:55:02.223] [Server thread/INFO]: Preparing world "world"
[17:55:02.226] [Server thread/NOTICE]: Spawn terrain for world "world" is being generated in the background
[17:55:02.230] [Server thread/INFO]: Enabling test v1.0.0
[17:55:02.280] [Server thread/INFO]: Minecraft network interface running on 0.0.0.0:15555
[17:55:02.281] [Server thread/INFO]: [Query Handler] GS4 Query listener running on 0.0.0.0:15555
[17:55:02.282] [Server thread/INFO]: Default game type: Survival Mode
[17:55:02.282] [Server thread/INFO]: If you find this project useful, please consider donating to support development: https://patreon.com/pocketminemp
[17:55:02.282] [Server thread/INFO]: Done (1.064s)! For help, type "help" or "?"
[17:55:02.292] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 1 / 224 (0%)
[17:55:02.378] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 23 / 224 (10%)
[17:55:02.838] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 1 / 224 (0%)
[17:55:04.770] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 23 / 224 (10%)
[17:55:04.980] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 45 / 224 (20%)
[17:55:05.422] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 45 / 224 (20%)
[17:55:05.453] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 68 / 224 (30%)
[17:55:05.743] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 68 / 224 (30%)
[17:55:05.764] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 90 / 224 (40%)
[17:55:05.955] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 90 / 224 (40%)
[17:55:06.026] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 112 / 224 (50%)
[17:55:06.184] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 112 / 224 (50%)
[17:55:06.313] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 135 / 224 (60%)
[17:55:06.360] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 135 / 224 (60%)
[17:55:06.485] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 157 / 224 (70%)
[17:55:06.533] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 157 / 224 (70%)
[17:55:06.661] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 180 / 224 (80%)
[17:55:06.708] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 180 / 224 (80%)
[17:55:06.794] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 202 / 224 (90%)
[17:55:06.836] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 202 / 224 (90%)
[17:55:06.946] [Server thread/INFO]: [World: target] Generating spawn terrain chunks: 224 / 224 (100%)
[17:55:06.963] [Server thread/INFO]: [World: world] Generating spawn terrain chunks: 224 / 224 (100%)
pl
[17:55:08.633] [Server thread/INFO]: Plugins (2): DevTools v1.15.0+dev, test v1.0.0
ver
[17:55:09.305] [Server thread/INFO]: This server is running PocketMine-MP
[17:55:09.305] [Server thread/INFO]: Server version: 4.0.0-BETA3 (git hash: 9bc07a9cc0ed1b653d961846a059049319c918d1)
[17:55:09.305] [Server thread/INFO]: Compatible Minecraft version: 1.17.30 (protocol version: 465)
[17:55:09.305] [Server thread/INFO]: PHP version: 8.0.10
[17:55:09.306] [Server thread/INFO]: PHP JIT: disabled
[17:55:09.306] [Server thread/INFO]: Operating system: win
[17:55:10.593] [Server thread/INFO]: [NetworkSession: 192.168.31.1 47128] Session opened
[17:55:10.621] [Server thread/INFO]: [NetworkSession: 192.168.31.1 47128] Player: L3S9
[17:55:11.030] [Server thread/INFO]: L3S9[/192.168.31.1:47128] logged in with entity id 1 at (world, 256, 66, 256)
[17:55:14.776] [Server thread/INFO]: L3S9 joined the game
[17:55:16.222] [Server thread/CRITICAL]: InvalidArgumentException: "Cannot add an Entity in an ungenerated chunk" (EXCEPTION) in "pmsrc/src/world/World" at line 2294
[17:55:16.222] [Server thread/CRITICAL]: #0 pmsrc/src/entity/Entity(1309): pocketmine\world\World->addEntity(object pocketmine\player\Player#38039)
[17:55:16.222] [Server thread/CRITICAL]: #1 pmsrc/src/player/Player(619): pocketmine\entity\Entity->setPosition(object pocketmine\world\Position#110811)
[17:55:16.222] [Server thread/CRITICAL]: #2 pmsrc/src/entity/Entity(1324): pocketmine\player\Player->setPosition(object pocketmine\world\Position#110811)
[17:55:16.222] [Server thread/CRITICAL]: #3 pmsrc/src/entity/Entity(1390): pocketmine\entity\Entity->setPositionAndRotation(object pocketmine\world\Position#110811, double 27.302352905273, double 89.901092529297)
[17:55:16.222] [Server thread/CRITICAL]: #4 pmsrc/src/player/Player(2249): pocketmine\entity\Entity->teleport(object pocketmine\world\Position#110811, NULL , NULL )
[17:55:16.222] [Server thread/CRITICAL]: #5 plugins/test/src/test/test(25): pocketmine\player\Player->teleport(object pocketmine\world\Position#110809)
[17:55:16.222] [Server thread/CRITICAL]: #6 pmsrc/src/event/RegisteredListener(75): test\test->tap(object pocketmine\event\player\PlayerInteractEvent#110813)
[17:55:16.222] [Server thread/CRITICAL]: #7 pmsrc/src/event/Event(62): pocketmine\event\RegisteredListener->callEvent(object pocketmine\event\player\PlayerInteractEvent#110813)
[17:55:16.222] [Server thread/CRITICAL]: #8 pmsrc/src/world/World(1802): pocketmine\event\Event->call()
[17:55:16.222] [Server thread/CRITICAL]: #9 pmsrc/src/player/Player(1603): pocketmine\world\World->useItemOn(object pocketmine\math\Vector3#110791, object pocketmine\item\ItemBlock#110806, integer 1, object pocketmine\math\Vector3#110821, object pocketmine\player\Player#38039, true)
[17:55:16.222] [Server thread/CRITICAL]: #10 pmsrc/src/network/mcpe/handler/InGamePacketHandler(374): pocketmine\player\Player->interactBlock(object pocketmine\math\Vector3#110791, integer 1, object pocketmine\math\Vector3#110821)
[17:55:16.223] [Server thread/CRITICAL]: #11 pmsrc/src/network/mcpe/handler/InGamePacketHandler(232): pocketmine\network\mcpe\handler\InGamePacketHandler->handleUseItemTransaction(object pocketmine\network\mcpe\protocol\types\inventory\UseItemTransactionData#110824)
[17:55:16.223] [Server thread/CRITICAL]: #12 pmsrc/vendor/pocketmine/bedrock-protocol/src/InventoryTransactionPacket(106): pocketmine\network\mcpe\handler\InGamePacketHandler->handleInventoryTransaction(object pocketmine\network\mcpe\protocol\InventoryTransactionPacket#110827)
[17:55:16.223] [Server thread/CRITICAL]: #13 pmsrc/src/network/mcpe/NetworkSession(384): pocketmine\network\mcpe\protocol\InventoryTransactionPacket->handle(object pocketmine\network\mcpe\handler\InGamePacketHandler#111794)
[17:55:16.223] [Server thread/CRITICAL]: #14 pmsrc/src/network/mcpe/NetworkSession(347): pocketmine\network\mcpe\NetworkSession->handleDataPacket(object pocketmine\network\mcpe\protocol\InventoryTransactionPacket#110827, string[39] .......A........Cr=.B...C.v.>...?...?.')
[17:55:16.223] [Server thread/CRITICAL]: #15 pmsrc/src/network/mcpe/raklib/RakLibInterface(188): pocketmine\network\mcpe\NetworkSession->handleEncoded(string[41] c.abT.c`b`......H3048...;.h...v@..a..}.:.)
[17:55:16.223] [Server thread/CRITICAL]: #16 pmsrc/vendor/pocketmine/raklib-ipc/src/RakLibToUserThreadMessageReceiver(42): pocketmine\network\mcpe\raklib\RakLibInterface->onPacketReceive(integer 0, string[50] .b..3........:..6..Mz..U ...swsL......]...P..b.x..)
[17:55:16.223] [Server thread/CRITICAL]: #17 pmsrc/src/network/mcpe/raklib/RakLibInterface(122): raklib\server\ipc\RakLibToUserThreadMessageReceiver->handle(object pocketmine\network\mcpe\raklib\RakLibInterface#25746)
[17:55:16.223] [Server thread/CRITICAL]: #18 pmsrc/vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\raklib\RakLibInterface->pocketmine\network\mcpe\raklib\{closure}()
[17:55:16.223] [Server thread/CRITICAL]: #19 pmsrc/vendor/pocketmine/snooze/src/SleeperHandler(82): pocketmine\snooze\SleeperHandler->processNotifications()
[17:55:16.223] [Server thread/CRITICAL]: #20 pmsrc/src/Server(1526): pocketmine\snooze\SleeperHandler->sleepUntil(double 1633168516.2382)
[17:55:16.223] [Server thread/CRITICAL]: #21 pmsrc/src/Server(1081): pocketmine\Server->tickProcessor()
[17:55:16.223] [Server thread/CRITICAL]: #22 pmsrc/src/PocketMine(300): pocketmine\Server->__construct(object BaseClassLoader#2, object pocketmine\utils\MainLogger#3, string[20] F:\testpm\4.0.0\tmp\, string[28] F:\testpm\4.0.0\tmp\plugins\)
[17:55:16.223] [Server thread/CRITICAL]: #23 pmsrc/src/PocketMine(323): pocketmine\server()
[17:55:16.223] [Server thread/CRITICAL]: #24 pmsrc(11): require(string[64] phar://F:/testpm/4.0.0/tmp/PocketMine-MP.phar/src/PocketMine.php)
[17:55:16.223] [Server thread/EMERGENCY]: An unrecoverable error has occurred and the server has crashed. Creating a crash dump
[17:55:16.229] [Server thread/EMERGENCY]: Please upload the "F:/testpm/4.0.0/tmp/crashdumps/Sat_Oct_2-17.55.16-AWST_2021.log" file to the Crash Archive and submit the link to the Bug Reporting page. Give as much info as you can.
[17:55:16.230] [Server thread/INFO]: Disabling DevTools v1.15.0+dev
[17:55:16.230] [Server thread/INFO]: Disabling test v1.0.0
[17:55:16.233] [Server thread/INFO]: L3S9 left the game
[17:55:16.235] [Server thread/INFO]: [NetworkSession: L3S9] Session closed due to Server closed
[17:55:16.236] [Server thread/INFO]: Unloading world "target"
[17:55:16.391] [Server thread/INFO]: Unloading world "world"
--- Waiting 104 seconds to throttle automatic restart (you can kill the process safely now) ---
bin\php\php.exe: Exit 1
dktapps commented 3 years ago

This is caused by the following dead code: https://github.com/pmmp/PocketMine-MP/blob/9bc07a9cc0ed1b653d961846a059049319c918d1/src/world/World.php#L2292-L2295

a leftover from https://github.com/pmmp/PocketMine-MP/commit/34f01a3ce3c02f41cfebfc81d34b755cfed62811