Interface "DateTimeInterface" not found
Description
composer.lock:
"name": "nesbot/carbon",
"version": "2.57.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "4a54375c21eea4811dbd1149fe6b246517554e78"
},
Sometimes I can see:

Obviously, there is an import. And yes, I double checked on the filesystem.
No idea how to reproduce. Looks like just one thread is buggy because the issue is intermittent. I experienced the same bug in prod (no XDebug comparing to my current setup) but that has fixed/doesn't fail anymore. These days it reproduces on local machine and I'm happy to help to debug/narrow down this therefore don't restart docker :).
A bit of info:
composer@php:/www/platform$ php -v
PHP 8.1.4 (cli) (built: Mar 18 2022 18:25:47) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.4, Copyright (c) Zend Technologies
with Zend OPcache v8.1.4, Copyright (c), by Zend Technologies
with Xdebug v3.1.3, Copyright (c) 2002-2022, by Derick Rethans
composer@php:/www/platform$ php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gmp
hash
iconv
igbinary
imagick
intl
json
libxml
mbstring
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Xdebug
Zend OPcache
PHP Version
8.1.4
Operating System
Docker php:8.1-fpm-bullseye
Does this also happen with OPcache disabled? If not, please try running OPcache without JIT, with function JIT and with tracing JIT. Would the issue happen then in all 3 cases?
Hi @cmb69 ,
Does this also happen with OPcache disabled?
I haven't tried. It's enabled on both prod and local.
If not, please try running OPcache without JIT, with function JIT and with tracing JIT. Would the issue happen then in all 3 cases?
I worry that issue will not be reproduced at all once I just restart the container. As I mentioned above, the same issue was happening on prod and that was temperamental, i.e. just restart of docker container helped to stop failures. Moreover not every deployment (starting containers with new version of images) caused such failures.
Maybe related: #8164
Maybe related: #8164
Wow! #8164 is exactly the bug we experienced on prod I referred above.
I have dumped opcache_get_status() to a file as @arnaud-lb has advised in the linked issue. It's 650kb long. Do you want me to share with you? Any sensitive data there?
Was it generated while the issue was happening ?
You can post it on gist.github.com or send it to my email. You may consider the filenames to be sensitive. You can redact them, but please let me know if the CarbonInterface.php file was listed in there.
@arnaud-lb , yes, I added a dumping line on top of the index.php prior even framework bootstrap and clicked Refresh till it failed :)
I redacted a little bit to skip my project's files. Yes, CarbonInterface presents in the list.
One detail you could be interested in — the issue happened at 1650065374 but such last_used_timestamp exists only for index.php but not for CarbonInterface (however, I assume a lot of frameworks classes (ClassLoader, Container, etc) should be marked the same as well, so the timestamp could be useless).
Thank you. Could you also share the opcache section of phpinfo() ? Are you using opcache.preload ? See also @cmb69's comment: knowing this would help to narrow the issue
@arnaud-lb , @cmb69 , here is an opcache section of ini_get_all():
opcache-ini.log
Thank you @SCIF
For now I haven't succeeded in reproducing the issue locally.
If someone else wants to look at this, here is what I tried: https://github.com/arnaud-lb/issue-8358
Hi @arnaud-lb ,
Appreaciate your efforts! Just to clarify — the issue I experienced in prod in past was not caused by opcache_reset() (at least I couldn't find any invoke of opcache_reset() in vendor/ and nothing in app/ dir).
The way we deploy prod is next:
- application image is built on CI and pushed to a registry
- new images pulled and new containers started on a prod servers
- the entrypoint of image looks like:
php artisan config:clear && php artisan route:clear && php artisan view:cache
php artisan someappcache:validate-rewarm
exec php-fpm
May be fixed by https://github.com/php/php-src/pull/8297
@SCIF, could you please check this? Either build from source, or wait for PHP 8.1.6RC1 which is supposed to released on April, 28th.
@arnaud-lb , thanks for your work an proposed fix! Could you please respond a few questions related?
- Did you manage to reproduce the bug?
- Does the bug in #8297 affect most likely one thread rather than all?
- Is there any way to prove that my failed php thread is buggy because of #8297 by running some php code? (I didn't restart my container so it still fails every 5-7 requests). May be because of having fix for the bug, you could imagine what can lead to coredumping/whatever-else-specific-for-damaged-threads so this way we would prove the idea :)
@cmb69 , unfortunately, I don't meet this bug often. I mean, that's the very first time I experienced it locally. And based on past experience I met it in prod, just restart of container (even don't need to rebuild it) will «fix» the issue.
I managed to produce a similar behavior (class not found caused by a leaked error), but I'm not sure that #8063 is the actual cause of this issue so I don't want to close it yet.
Does the bug in https://github.com/php/php-src/pull/8297 affect most likely one thread rather than all?
That's unlikely to affect only one thread.
Is there any way to prove that my failed php thread is buggy because of https://github.com/php/php-src/pull/8297 ?
If the issue disappears after an opcache_reset(), there is a chance it's related to that. Otherwise, probably not.
Hi @arnaud-lb ,
Thanks for the explanation!
I added opcache_reset(); at the very top of index.php and issue persists still :/
A similar problem occurs with functions. Now in production, with some periodicity, we catch errors of the lack of standard functions, like: Call to undefined function Monolog\Processor\memory_get_peak_usage().
So far, we are solving by restarting the docker container.
I am going to close this as it looks like a duplicate of #8164 which has been fixed.
If not, please open a new issue.