DiscordPHP icon indicating copy to clipboard operation
DiscordPHP copied to clipboard

loadAllMembers does not work on 32-bits PHP with large guilds

Open SQKo opened this issue 2 years ago • 1 comments

EDIT: Temporary fix by applying composer require ratchet/rfc6455:"dev-master#82760a7 as 0.3.1


Enabling loadAllMembers options running on 32-bits PHP when the bot is at least in one of guild considered "large" will crash after chunking up the members:

[2022-01-20T04:29:43.510365+00:00] DiscordPHP.DEBUG: guild available {"guild":"872531095621615646","unavailable":1} []
[2022-01-20T04:29:43.511365+00:00] DiscordPHP.INFO: all guilds are now available {"count":2} []
[2022-01-20T04:29:43.511365+00:00] DiscordPHP.INFO: set up chunking, checking for chunks every 5 seconds [] []
[2022-01-20T04:29:43.511365+00:00] DiscordPHP.DEBUG: sending 1 chunks with 2 large guilds overall [] []
[2022-01-20T04:29:43.511365+00:00] DiscordPHP.DEBUG: sending chunk with 2 large guilds [] []
PHP Warning:  unpack(): 64-bit format codes are not available for 32-bit versions of PHP in D:\Install\discord-php-bot\vendor\ratchet\rfc6455\src\Messaging\MessageBuffer.php on line 163
PHP Notice:  Trying to access array offset on value of type bool in D:\Install\discord-php-bot\vendor\ratchet\rfc6455\src\Messaging\MessageBuffer.php on line 163
PHP Fatal error:  Uncaught UnderflowException: Frame must be coalesced before applying mask in D:\Install\discord-php-bot\vendor\ratchet\rfc6455\src\Messaging\Frame.php:78
Stack trace:
#0 [internal function]: Ratchet\RFC6455\Messaging\Frame::Ratchet\RFC6455\Messaging\{closure}()
#1 D:\Install\discord-php-bot\vendor\ratchet\rfc6455\src\Messaging\Frame.php(287): call_user_func()
#2 D:\Install\discord-php-bot\vendor\ratchet\rfc6455\src\Messaging\MessageBuffer.php(216): Ratchet\RFC6455\Messaging\Frame->unMaskPayload()
#3 D:\Install\discord-php-bot\vendor\ratchet\rfc6455\src\Messaging\MessageBuffer.php(194): Ratchet\RFC6455\Messaging\MessageBuffer->processData()
#4 D:\Install\discord-php-bot\vendor\evenement\evenement\src\Evenement\EventEmitterTrait.php(123):
Ratchet\RFC6455\Messaging\MessageBuffer->onData()
#5 D:\Install\discord-php-bot\vendor\react\stream\src\Util.php(71): Evenement\EventEmitter->emit()
#6 D:\Install\discord-php-bot\vendor\evenement\evenement\src\Evenement\EventEmitterTrait.php(123):
React\Stream\Util::React\Stre in D:\Install\discord-php-bot\vendor\ratchet\rfc6455\src\Messaging\Frame.php on line 78

Stable v6.0.3 is also affected.

Might be related to the ratchetphp library.

Fixed by https://github.com/ratchetphp/RFC6455/pull/65

Note: the fix only increased payload limit from 65 KB to 2 GB. Don't expect a 32-bits php can store all members in a very large guild with thousands of members going over 2 GB, that crash would simply mean you need more RAM and 64-bits php to cover it.

SQKo avatar Jan 21 '22 13:01 SQKo

Since the PR is now merged (not released yet), you can temporarily apply the patch by: composer require ratchet/rfc6455:"dev-master#82760a7 as 0.3.1

We'll add the patched version to requirements ASAP once it's released.

SQKo avatar Aug 17 '22 18:08 SQKo