Problem/Motivation
2 tesst fails on PHP 8.1rc4 because usleep() expects integer argument but microtime(TRUE) returns float
- core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php
- core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
Steps to reproduce
Ref to CI
and
$ php -r '$t=microtime(TRUE)+0.5;usleep(($t - microtime(TRUE)) * 1000000);'
PHP Deprecated: Implicit conversion from float 499994.99320983887 to int loses precision in Command line code on line 1
Deprecated: Implicit conversion from float 499994.99320983887 to int loses precision in Command line code on line 1
Proposed resolution
fix code
Remaining tasks
review, commit
User interface changes
no
API changes
no
Data model changes
no
Release notes snippet
no
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3244533-6.patch | 1.58 KB | daffie |
Comments
Comment #2
andypostComment #3
andyposthttps://3v4l.org/OQ2va only one deprecation now
Comment #4
andypostfound one more hunk to fix by checking usage of
usleep()in corere-title and updated IS
Comment #5
andypostFix CS
Comment #6
daffie commentedI think that the reason that the testbot is failing for PHP 8.1-rc4 is that we should first multiply with a million and after that do the casting to an integer value. The required precision gets lost if you do it in the reverse order.
Comment #7
alexpottSegfault! Wow nice.
Comment #8
andypostI can't reproduce it locally, guess it needs specific conditions or set of libs
Comment #9
daffie commentedMaybe a bug in PHP 8.1?
Comment #10
alexpott@daffie it might be a bug in RC4 that's been fixed - I only have the latest dev version.
Comment #11
andypostHow to find which docker image is used in CI to run it locally? I'm using custom Alpinelinux docker image based on https://pkgs.alpinelinux.org/packages?name=php81-*&branch=edge&arch=x86_64 and can't reproduce it locally(
Comment #12
daffie commentedI have DDEV with PHP 8.1 rc-2 and I can confirm that I get the "Segmentation fault" error on my local machine.
Without the patch applied I get the same "Segmentation fault" error on my local machine.
To me, it looks like the error is fixed in PHP 8.1-dev.
Comment #13
andypost@daffie how you able to reproduce? just running test?
Comment #14
daffie commentedYes, just running a single test. Sometimes it will pass and sometimes it will fail.
Comment #15
andypostI think segfault needs infra issue but the patch is good to go
Added I'm using this script to test
seq 64 | parallel -j 8 "echo job {#} of {= '$_=total_jobs()' =} && php81 vendor/bin/phpunit -c core/phpunit.xml.dist core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php"Comment #17
catchCommitted 54147fd and pushed to 9.3.x. Thanks!