php-src icon indicating copy to clipboard operation
php-src copied to clipboard

Interface "DateTimeInterface" not found

Open SCIF opened this issue 4 years ago • 18 comments

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: image

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

SCIF avatar Apr 13 '22 09:04 SCIF

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?

cmb69 avatar Apr 13 '22 16:04 cmb69

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.

SCIF avatar Apr 13 '22 20:04 SCIF

Maybe related: #8164

arnaud-lb avatar Apr 15 '22 18:04 arnaud-lb

Maybe related: #8164

Wow! #8164 is exactly the bug we experienced on prod I referred above.

SCIF avatar Apr 15 '22 21:04 SCIF

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?

SCIF avatar Apr 15 '22 23:04 SCIF

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 avatar Apr 16 '22 14:04 arnaud-lb

@arnaud-lb , yes, I added a dumping line on top of the index.php prior even framework bootstrap and clicked Refresh till it failed :)

1.log

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).

SCIF avatar Apr 16 '22 21:04 SCIF

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 avatar Apr 16 '22 22:04 arnaud-lb

@arnaud-lb , @cmb69 , here is an opcache section of ini_get_all(): opcache-ini.log

SCIF avatar Apr 17 '22 00:04 SCIF

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

arnaud-lb avatar Apr 17 '22 08:04 arnaud-lb

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:

  1. application image is built on CI and pushed to a registry
  2. new images pulled and new containers started on a prod servers
  3. 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

SCIF avatar Apr 17 '22 10:04 SCIF

May be fixed by https://github.com/php/php-src/pull/8297

arnaud-lb avatar Apr 22 '22 16:04 arnaud-lb

@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.

cmb69 avatar Apr 22 '22 16:04 cmb69

@arnaud-lb , thanks for your work an proposed fix! Could you please respond a few questions related?

  1. Did you manage to reproduce the bug?
  2. Does the bug in #8297 affect most likely one thread rather than all?
  3. 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.

SCIF avatar Apr 22 '22 21:04 SCIF

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.

arnaud-lb avatar Apr 23 '22 10:04 arnaud-lb

Hi @arnaud-lb ,

Thanks for the explanation! I added opcache_reset(); at the very top of index.php and issue persists still :/

SCIF avatar Apr 23 '22 10:04 SCIF

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.

SerafimArts avatar Apr 25 '22 09:04 SerafimArts

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.

Girgias avatar Jun 02 '24 16:06 Girgias