Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP8 Compatibility - TypeError: mb_substr(): Argument #3 ($length) must be of type ?int, null given #26

Closed
PhilETaylor opened this issue Nov 4, 2020 · 3 comments

Comments

@PhilETaylor
Copy link

PhilETaylor commented Nov 4, 2020

Edit: So for hours now I have been trying to get to the bottom of this to give you more details.

All I have managed to find out is that it only effects PHP 8 RC3 when JIT Enabled.

It doesn't always happen either... I cannot get a reliable reproducer - except that when I deploy to production it reproduces within moments and kills my live service.

I cannot replicate ever - even in production - when PHP preloading & JIT is disabled.

return \mb_substr($str, $start, $length, '8bit');

TypeError: mb_substr(): Argument #3 ($length) must be of type ?int, null given
#34 /vendor/paragonie/constant_time_encoding/src/Binary.php(76): mb_substr
#33 /vendor/paragonie/constant_time_encoding/src/Binary.php(76): ParagonIE\ConstantTime\Binary::safeSubstr
#32 /vendor/paragonie/hidden-string/src/HiddenString.php(173): ParagonIE\HiddenString\HiddenString::safeStrcpy
#31 /vendor/paragonie/hidden-string/src/HiddenString.php(56): ParagonIE\HiddenString\HiddenString::__construct
#30 /vendor/paragonie/halite/src/Symmetric/Crypto.php(208): ParagonIE\Halite\Symmetric\Crypto::decryptWithAd
#29 /vendor/paragonie/halite/src/Symmetric/Crypto.php(105): ParagonIE\Halite\Symmetric\Crypto::decrypt
#28 /vendor/philetaylor/doctrine-encrypt/Encryptors/HaliteEncryptor.php(82): Philetaylor\DoctrineEncryptBundle\Encryptors\HaliteEncryptor::decrypt
@PhilETaylor PhilETaylor changed the title PHP8 Compatibility PHP8 Compatibility - TypeError: mb_substr(): Argument #3 ($length) must be of type ?int, null given Nov 4, 2020
@paragonie-security
Copy link
Contributor

That doesn't make any sense. ?int means int, but nullable. This is probably a bug in PHP 8.

@PhilETaylor
Copy link
Author

yes, I agree the error message is insane, Ive seen a few insane messages like this since testing PHP 8 that just make no sense.

Im happy to close this and leave it until PHP 8 becomes more stable. But its here as a record if others get the same issue but have more detail to help replicate it.

I could only ever replicate when using OPcache.preload in php.ini and not when preloading files after fpm loaded.

@paragonie-security
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants