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.55k forks source link

Undefined array key - by using CPlot PlugIN #5713

Closed krake79 closed 1 year ago

krake79 commented 1 year ago

Issue description

I'm running CPlot_dev142 and the current PM4.19.2. If I now want to add a claim, I get an error message:

ErrorException: "Undefined array key 5" (EXCEPTION) in "pmsrc/src/event/HandlerList" at line 105

Steps to reproduce the issue

Command: /P claim

OS and versions

Plugins

Crashdump, backtrace or other files

[Server thread/CRITICAL]: ErrorException: "Undefined array key 5" (EXCEPTION) in "pmsrc/src/event/HandlerList" at line 105
--- Stack trace ---
  #0 pmsrc/src/event/HandlerList(105): pocketmine\errorhandler\ErrorToExceptionHandler::handle(int 2, string[21] Undefined array key 5, string[104] phar://C:/PM/PocketMine-MP.phar/s, int 105)
  #1 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/ColinHDev/libAsyncEvent/AsyncEvent(67): pocketmine\event\HandlerList->getListenersByPriority(int 5)
  #2 (): ColinHDev\CPlot\libs\ColinHDev\libAsyncEvent\AsyncEvent->getEventHandlers()
  #3 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/ColinHDev/libAsyncEvent/AsyncEvent(44): Generator->valid()
  #4 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/ColinHDev/libAsyncEvent/AsyncEvent(27): ColinHDev\CPlot\libs\ColinHDev\libAsyncEvent\AsyncEvent->tryToResume()
  #5 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/event/PlotClaimAsyncEvent(38): ColinHDev\CPlot\libs\ColinHDev\libAsyncEvent\AsyncEvent->call()
  #6 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(212): ColinHDev\CPlot\event\PlotClaimAsyncEvent::ColinHDev\CPlot\event\{closure}(object Closure#240483, object Closure#217998)
  #7 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/event/PlotClaimAsyncEvent(42): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await::promise(object Closure#218083)
  #8 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/commands/subcommands/ClaimSubcommand(93): ColinHDev\CPlot\event\PlotClaimAsyncEvent::create(object ColinHDev\CPlot\plots\Plot#186405, object pocketmine\player\Player#129736)
  #9 (): ColinHDev\CPlot\commands\subcommands\ClaimSubcommand->execute(object pocketmine\player\Player#129736, array[0])
  #10 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(286): Generator->send(object Closure#217998)
  #11 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(242): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->ColinHDev\CPlot\libs\SOFe\AwaitGenerator\{closure}()
  #12 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(227): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->wakeup(object Closure#240469)
  #13 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(462): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->wakeupFlat(object Closure#240469)
  #14 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/AwaitChild(52): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->recheckPromiseQueue(object ColinHDev\CPlot\libs\SOFe\AwaitGenerator\AwaitChild#218001)
  #15 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/utils/promise/PromiseResolver(37): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\AwaitChild->resolve(array[1])
  #16 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/utils/promise/PromiseResolver(53): ColinHDev\CPlot\utils\promise\PromiseResolver->resolve(array[1])
  #17 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/CPlotAPI(421): ColinHDev\CPlot\utils\promise\PromiseResolver->resolveSilent(array[1])
  #18 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(480): ColinHDev\CPlot\CPlotAPI::ColinHDev\CPlot\{closure}(array[1])
  #19 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(250): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->resolve(array[1])
  #20 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(227): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->wakeup(object Closure#240474)
  #21 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(462): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->wakeupFlat(object Closure#240474)
  #22 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/AwaitChild(52): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->recheckPromiseQueue(object ColinHDev\CPlot\libs\SOFe\AwaitGenerator\AwaitChild#234463)
  #23 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(480): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\AwaitChild->resolve(object ColinHDev\CPlot\plots\Plot#234452)
  #24 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(250): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->resolve(object ColinHDev\CPlot\plots\Plot#234452)
  #25 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(227): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->wakeup(object Closure#240465)
  #26 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/Await(462): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->wakeupFlat(object Closure#240465)
  #27 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/SOFe/AwaitGenerator/AwaitChild(52): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\Await->recheckPromiseQueue(object ColinHDev\CPlot\libs\SOFe\AwaitGenerator\AwaitChild#240161)
  #28 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/poggit/libasynql/base/DataConnectorImpl(197): ColinHDev\CPlot\libs\SOFe\AwaitGenerator\AwaitChild->resolve(array[0])
  #29 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/poggit/libasynql/base/DataConnectorImpl(174): ColinHDev\CPlot\libs\poggit\libasynql\base\DataConnectorImpl::ColinHDev\CPlot\libs\poggit\libasynql\base\{closure}(array[0], array[0])
  #30 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/poggit/libasynql/base/DataConnectorImpl(181): ColinHDev\CPlot\libs\poggit\libasynql\base\DataConnectorImpl::ColinHDev\CPlot\libs\poggit\libasynql\base\{closure}(object ColinHDev\CPlot\libs\poggit\libasynql\result\SqlSelectResult#240120)
  #31 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/poggit/libasynql/base/DataConnectorImpl(239): ColinHDev\CPlot\libs\poggit\libasynql\base\DataConnectorImpl::ColinHDev\CPlot\libs\poggit\libasynql\base\{closure}(array[1])
  #32 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/poggit/libasynql/base/SqlThreadPool(112): ColinHDev\CPlot\libs\poggit\libasynql\base\DataConnectorImpl->ColinHDev\CPlot\libs\poggit\libasynql\base\{closure}(array[1])
  #33 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/poggit/libasynql/base/DataConnectorImpl(322): ColinHDev\CPlot\libs\poggit\libasynql\base\SqlThreadPool->readResults(array[13])
  #34 plugins/CPlot_dev-142.phar/src/ColinHDev/CPlot/libs/poggit/libasynql/base/SqlThreadPool(65): ColinHDev\CPlot\libs\poggit\libasynql\base\DataConnectorImpl->checkResults()
  #35 pmsrc/vendor/pocketmine/snooze/src/SleeperHandler(123): ColinHDev\CPlot\libs\poggit\libasynql\base\SqlThreadPool->ColinHDev\CPlot\libs\poggit\libasynql\base\{closure}()
  #36 pmsrc/src/TimeTrackingSleeperHandler(58): pocketmine\snooze\SleeperHandler->processNotifications()
  #37 pmsrc/vendor/pocketmine/snooze/src/SleeperHandler(82): pocketmine\TimeTrackingSleeperHandler->processNotifications()
  #38 pmsrc/src/Server(1681): pocketmine\snooze\SleeperHandler->sleepUntil(float 1681928384.7946)
  #39 pmsrc/src/Server(1061): pocketmine\Server->tickProcessor()
  #40 pmsrc/src/PocketMine(339): pocketmine\Server->__construct(object BaseClassLoader#5, object pocketmine\utils\MainLogger#2, string[53] C:\Users\Gamesucht\Desktop\PocketMine Live bei Crash\, string[61] C:\Users\Gamesucht\Desktop\PocketMine Live bei Crash\plugins\)
  #41 pmsrc/src/PocketMine(362): pocketmine\server()
  #42 pmsrc(11): require(string[97] phar://C:/PM/PocketMine Live bei Crash/PocketMine-MP.phar/s)
--- End of exception information ---
jasonw4331 commented 1 year ago

The problem is HandlerList::getListenersByPriority() triggering a crash on a valid priority number. Reproducing code:

        $handlerList = HandlerListManager::global()->getListFor(get_class($this));
        foreach (EventPriority::ALL as $priority) {
            $currentList = $handlerList;
            while ($currentList !== null) {
                foreach ($currentList->getListenersByPriority($priority) as $registration) {
                    yield $registration;
                }
                $currentList = $currentList->getParent();
            }
        }
dktapps commented 1 year ago

@SOF3 Maybe explore whether that code can be simplified by getListenerList() in 4.19?