SOF3 / await-generator

Write code in async/await style in PHP using generators.
https://sof3.github.io/await-generator/master/
Apache License 2.0
123 stars 15 forks source link

Channel tries to call null function #200

Open SOF3 opened 1 year ago

SOF3 commented 1 year ago
Error: "Value of type null is not callable" (EXCEPTION) in "/home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_aeb2c40fe5790109/SOFe/AwaitGenerator/Channel" at line 52
  #0 (): libs\_aeb2c40fe5790109\SOFe\AwaitGenerator\Channel->sendAndWait(object pocketmine\event\player\PlayerMoveEvent#128506)
  #1 /home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_aeb2c40fe5790109/SOFe/AwaitGenerator/Await(332): Generator->rewind()
  #2 /home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_aeb2c40fe5790109/SOFe/AwaitGenerator/Await(129): libs\_aeb2c40fe5790109\SOFe\AwaitGenerator\Await->wakeup(array[2])
  #3 /home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_aeb2c40fe5790109/SOFe/AwaitGenerator/Channel(85): libs\_aeb2c40fe5790109\SOFe\AwaitGenerator\Await::g2c(object Generator#128426)
  #4 /home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_aeb2c40fe5790109/SOFe/WebConsole/Lib/Util(36): libs\_aeb2c40fe5790109\SOFe\AwaitGenerator\Channel->sendWithoutWait(object pocketmine\event\player\PlayerMoveEvent#128506)
  #5 pmsrc/src/event/RegisteredListener(60): libs\_aeb2c40fe5790109\SOFe\WebConsole\Lib\Util::libs\_aeb2c40fe5790109\SOFe\WebConsole\Lib\{closure}(object pocketmine\event\player\PlayerMoveEvent#128506)
  #6 pmsrc/src/event/Event(62): pocketmine\event\RegisteredListener->callEvent(object pocketmine\event\player\PlayerMoveEvent#128506)
  #7 pmsrc/src/player/Player(1277): pocketmine\event\Event->call()
  #8 pmsrc/src/player/Player(1368): pocketmine\player\Player->processMostRecentMovements()
  #9 pmsrc/src/world/World(976): pocketmine\player\Player->onUpdate(int 130)
  #10 pmsrc/src/world/World(902): pocketmine\world\World->actuallyDoTick(int 130)
  #11 pmsrc/src/world/WorldManager(350): pocketmine\world\World->doTick(int 130)
  #12 pmsrc/src/Server(1815): pocketmine\world\WorldManager->tick(int 130)
  #13 pmsrc/src/Server(1697): pocketmine\Server->tick()
  #14 pmsrc/src/Server(1056): pocketmine\Server->tickProcessor()
  #15 pmsrc/src/PocketMine(339): pocketmine\Server->__construct(object BaseClassLoader#2, object pocketmine\utils\MainLogger#5, string[41] /home/sofe/proj/WebConsole/local/install/, string[49] /home/sofe/proj/WebConsole/local/install/plugins/)
  #16 pmsrc/src/PocketMine(362): pocketmine\server()
  #17 pmsrc(11): require(string[85] phar:///home/sofe/proj/WebConsole/local/install/PocketMine-MP.phar/src/PocketMin)
SOF3 commented 1 year ago

Caused by unset not resetting the type of $this->state to EmptyChannelState.

SOF3 commented 1 year ago

Still reproduced in 3.5.2

SOF3 commented 1 year ago

initial debugging seems to suggest that this was caused by a race condition when interrupt/receive happens recursively on the same traverser.


#0 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Traverser.php(113): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\InterruptException::get()
#1 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/WatchHandler.php(515): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Traverser->interrupt()
#2 [internal function]: SOFe\WebConsole\Internal\WatchHandler->watchObjectField(Object(SOFe\WebConsole\Api\FieldDef), Object(libs\_d70aac9e1f8b3404\SOFe\WebConsole\Lib\StreamingObject), Object(libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Loading), Object(libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Traverser))
#3 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(410): Generator->send(Array)
#4 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(332): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await->libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\{closure}()
#5 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(129): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await->wakeup(Object(Closure))
#6 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/WatchHandler.php(456): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await::g2c(Object(Generator))
#7 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/WatchHandler.php(404): SOFe\WebConsole\Internal\WatchHandler->handleAddEvent(Object(libs\_d70aac9e1f8b3404\SOFe\WebConsole\Lib\StreamingObject), '000000000000000...')
#8 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/Handler.php(189): SOFe\WebConsole\Internal\WatchHandler->watchObjects()
#9 [internal function]: SOFe\WebConsole\Internal\Handler->SOFe\WebConsole\Internal\{closure}()
#10 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(458): Generator->send(Array)
#11 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(332): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await->libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\{closure}()
#12 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(129): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await->wakeup(Object(Closure))
#13 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(102): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await::g2c(Object(Generator), NULL, Array)
#14 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/Handler.php(196): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await::f2c(Object(Closure))
#15 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/Handler.php(100): SOFe\WebConsole\Internal\Handler->watchList(Object(SOFe\WebConsole\Api\ObjectDef), Object(Closure), NULL)
#16 [internal function]: SOFe\WebConsole\Internal\Handler->SOFe\WebConsole\Internal\{closure}()
#17 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Traverser.php(68): Generator->valid()
#18 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/HttpClient.php(212): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Traverser->next(NULL)
#19 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/HttpClient.php(161): SOFe\WebConsole\Internal\HttpClient->run(Object(Closure))
#20 [internal function]: SOFe\WebConsole\Internal\HttpClient->SOFe\WebConsole\Internal\{closure}()
#21 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(553): Generator->send('GET /main/log-m...')
#22 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(332): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await->libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\{closure}()
#23 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(317): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await->wakeup(Object(Closure))
#24 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/Await.php(554): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await->wakeupFlat(Object(Closure))
#25 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/libs/_d70aac9e1f8b3404/SOFe/AwaitGenerator/AwaitChild.php(52): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\Await->recheckPromiseQueue(Object(libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\AwaitChild))
#26 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/HttpClient.php(269): libs\_d70aac9e1f8b3404\SOFe\AwaitGenerator\AwaitChild->resolve('GET /main/log-m...')
#27 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/HttpClient.php(277): SOFe\WebConsole\Internal\HttpClient->SOFe\WebConsole\Internal\{closure}()
#28 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/HttpServer.php(108): SOFe\WebConsole\Internal\HttpClient->tick()
#29 phar:///home/sofe/proj/WebConsole/local/WebConsole.phar/src/SOFe/WebConsole/Internal/Main.php(50): SOFe\WebConsole\Internal\HttpServer->tick()
#30 phar:///home/sofe/proj/WebConsole/local/install/PocketMine-MP.phar/src/scheduler/ClosureTask.php(57): SOFe\WebConsole\Internal\Main->SOFe\WebConsole\Internal\{closure}()```