php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81673 Tracing JIT causing various errors (trait related?)
Submitted: 2021-11-29 22:02 UTC Modified: -
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: eric at ericstern dot com Assigned:
Status: Open Package: JIT
PHP Version: 8.0.13 OS: Alpine linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
14 - 7 = ?
Subscribe to this entry?

 
 [2021-11-29 22:02 UTC] eric at ericstern dot com
Description:
------------
When enabling the JIT in a production environment, I started getting various errors in third-party libraries (guzzlehttp/psr7, though I doubt it's relevant). After some poking and prodding, I was able to narrow it down to the JIT running in `tracing` mode (via "on" or explicitly "tracing"). Turning it back off or running it in "function" mode made the errors disappear.

Notably, if I'm following my logs correctly, the first job seems to run fine. It's only on the second+ job where the error comes up.

The errors that occurred included:

TypeError: GuzzleHttp\Psr7\Request::getBody(): Return value must be of type Psr\Http\Message\StreamInterface, null returned in /var/www/html/vendor/guzzlehttp/psr7/src/MessageTrait.php:127

Error: Cannot use object of type GuzzleHttp\Psr7\Uri as array in /var/www/html/vendor/guzzlehttp/psr7/src/MessageTrait.php:161

(see linked file below)

In both cases, the errors make absolutely no sense for the given source code, especially the latter. Which error I get seems basically random, though the latter seems more common for any given worker. My gut tells me the issue is somehow specific to traits, but I don't have any practical way to verify that.

INI settings:
opcache.enable="1"
opcache.enable_cli="1"
(typical opcache prod values, preloading is enabled)
opcache.jit="on"
opcache.jit_buffer_size="128M"

Test script:
---------------
https://github.com/Firehed/php-jit-tracing-error - this doesn't actually reproduce the issue (yet), but it shows the approximate code structure where it occurs.

The surrounding infrastructure/code in prod is fairly long and complex, so I'm not sure how much needs to get added in to reproduce the issue. But it's a run loop for an async job worker which performs a network request and then parses and stores the results in a database. Nothing too special. The code in question has been live for months without ever having an issue.

Errors originate in this file:

https://github.com/guzzle/psr7/blob/2.1.0/src/MessageTrait.php

Expected result:
----------------
No errors

Actual result:
--------------
One backtrace:

TypeError: GuzzleHttp\Psr7\Request::getBody(): Return value must be of type Psr\Http\Message\StreamInterface, null returned in /var/www/html/vendor/guzzlehttp/psr7/src/MessageTrait.php:127
Stack trace:
#0 /var/www/html/vendor/guzzlehttp/psr7/src/Utils.php(222): GuzzleHttp\Psr7\Request->getBody()
#1 /var/www/html/vendor/guzzlehttp/guzzle/src/Client.php(440): GuzzleHttp\Psr7\Utils::modifyRequest(Object(GuzzleHttp\Psr7\Request), Array)
#2 /var/www/html/vendor/guzzlehttp/guzzle/src/Client.php(326): GuzzleHttp\Client->applyOptions(Object(GuzzleHttp\Psr7\Request), Array)
#3 /var/www/html/vendor/guzzlehttp/guzzle/src/Client.php(107): GuzzleHttp\Client->transfer(Object(GuzzleHttp\Psr7\Request), Array)
#4 /var/www/html/vendor/guzzlehttp/guzzle/src/Client.php(123): GuzzleHttp\Client->sendAsync(Object(GuzzleHttp\Psr7\Request), Array)
#5 /var/www/html/src/Worker/FetchStoreData.php(241): GuzzleHttp\Client->send(Object(GuzzleHttp\Psr7\Request), Array)
#6 /var/www/html/src/Console/Worker/Run.php(213): Slant\Normalizer\Worker\FetchStoreData->doJob(Array)
#7 [internal function]: Slant\Normalizer\Console\Worker\Run->Slant\Normalizer\Console\Worker\{closure}(Object(Kicken\Gearman\Job\WorkerJob))
#8 /var/www/html/vendor/kicken/gearman-php/src/Worker.php(194): call_user_func(Object(Closure), Object(Kicken\Gearman\Job\WorkerJob))
#9 /var/www/html/vendor/kicken/gearman-php/src/Worker.php(177): Kicken\Gearman\Worker->processJob(Object(Kicken\Gearman\Protocol\Packet))
#10 /var/www/html/vendor/kicken/gearman-php/src/Worker.php(116): Kicken\Gearman\Worker->processPacket(Object(Kicken\Gearman\Protocol\Packet))
#11 /var/www/html/src/Console/Worker/Run.php(145): Kicken\Gearman\Worker->workOnce()
#12 /var/www/html/vendor/symfony/console/Command/Command.php(299): Slant\Normalizer\Console\Worker\Run->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/vendor/symfony/console/Application.php(295): Symfony\Component\Console\Application->doRunCommand(Object(Slant\Normalizer\Console\Worker\Run), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/bin/app(63): Symfony\Component\Console\Application->run()
#17 {main}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-30 00:47 UTC] julien dot boudry at gmail dot com
Not exactly the same error, but the same context, only with tracing mode. And the code use trait too.
https://bugs.php.net/bug.php?id=81432
 [2023-01-27 11:55 UTC] rtsonldspj11 at gmail dot com
A commitment of appreciation is all together for the data. I will endeavor to figure it out for extra. (https://www.readypayonline.me/)github.com
 [2023-04-13 15:53 UTC] ascanpardinum at gmail dot com
(https://www.metooo.io/u/jasa-pembuatan-website).php.net
(https://steamcommunity.com/id/astraleliteforce/).php.net
 [2023-04-25 10:12 UTC] fariba dot shami326 at gmail dot com
Tracing JIT (Just-In-Time) compilers are a type of JIT compiler that compile sections of code at runtime based on the execution patterns of that code. While Tracing JITs can improve performance by generating optimized machine code, they can also introduce new errors and bugs that may be difficult to diagnose.

One common issue with Tracing JITs is related to object-oriented programming and the use of traits. Traits are a way to reuse code by encapsulating a set of methods that can be applied to different classes. However, traits can make it difficult for Tracing JITs to optimize code, as they may need to track multiple execution paths for each trait.

To avoid errors related to Tracing JITs and traits, you may need to modify your code to make it more amenable to optimization. This may involve simplifying complex inheritance hierarchies, minimizing the use of traits, or using other techniques to reduce the number of execution paths that need to be tracked.
(https://www.questdiagnosticsbill.me/)github.com
 [2023-05-02 12:25 UTC] joanwest23 at aol dot com
(https://www.linkedin.com/pulse/augusta-precious-metals-review-best-gold-ira-company-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/goldco-review-gold-ira-rollover-precious-metal-company-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/how-apply-employee-retention-credit-erc-complete-guide-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/best-gold-ira-companies-investment-retirement-accounts-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/ira-allowable-precious-metals-best-ira-approved-metal-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/roth-gold-ira-account-best-companies-how-works-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/what-employee-retention-tax-credit-ertc-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/best-precious-metals-ira-2023-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/best-silver-ira-companies-2023-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/how-protect-your-401k-from-market-crash-recession-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/goldco-vs-augusta-precious-metals-which-best-gold-ira-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/how-move-401k-gold-ira-without-penalty-jeffrey-keever/)github.com 
(https://www.linkedin.com/pulse/how-buy-physical-gold-your-401k-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/noble-gold-investments-review-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/best-paying-jobs-precious-metals-jeffrey-keever/)github.com
(https://www.linkedin.com/pulse/how-buy-gold-ira-jeffrey-keever-1e/)github.com
 [2023-05-03 02:29 UTC] kevinlove12w at aol dot com
(https://www.cameo.com/jeremypiven)github.com
(https://www.facebook.com/jeremypivenpage/)github.com
(https://www.amazon.com/prime-video/actor/Jeremy-Piven/amzn1.dv.gti.785e61d6-1dd8-4777-88c4-b33c24097594)github.com
(https://pixarcars.fandom.com/wiki/Jeremy_Piven)github.com
(https://www.eonline.com/news/1371236/jeremy-piven-teases-his-idea-for-entourage-reboot)github.com
(https://www.rottentomatoes.com/celebrity/jeremy_piven)github.com
(https://twitter.com/jeremypiven)github.com
(https://www.emmys.com/bios/jeremy-piven)github.com
(https://www.blu-ray.com/Jeremy-Piven/70580/)github.com
(https://ramentertainment.com/jeremy-piven)github.com
(https://podcasts.apple.com/us/podcast/the-big-shark-jeremy-piven/id1558354780?i=1000608694599)github.com
(https://www.etonline.com/people/jeremy-piven)github.com
(https://www.ibdb.com/broadway-cast-staff/jeremy-piven-405986)github.com
(https://abcnews.go.com/GMA/Culture/video/jeremy-piven-talks-new-movie-sweetwater-98145023)github.com
(https://www.eonline.com/news/1371236/jeremy-piven-teases-his-idea-for-entourage-reboot)github.com
(https://www.youtube.com/watch?v=RtQRmT2cSAM)github.com
(https://www.instagram.com/jeremypiven/)github.com
(https://www.imdb.com/name/nm0005315/)github.com
(https://www.tvguide.com/celebrities/jeremy-piven/credits/3000397119/)github.com
(https://www.tcm.com/tcmdb/person/153053%7C174725/Jeremy-Piven#overview)github.com
(https://www.bravotv.com/watch-what-happens-live-with-andy-cohen/season-12/episode-96/videos/jeremy-pivens-mercury-poisoning)github.com
(https://www.tvinsider.com/people/jeremy-piven/)github.com
(https://en.wikipedia.org/wiki/Jeremy_Piven)github.com
(https://www.primetimer.com/item/Jeremy-Piven-to-host-celebrity-interview-podcast-How-U-Livin-J-Piven-WoSpdw)github.com
(https://www.imdb.com/name/nm0005315/news)github.com
(https://en.wikipedia.org/wiki/Jeremy_Piven)github.com
(https://www.the-sun.com/entertainment/tv/3810895/jeremy-piven-reveals-entourage-return-woke-twist-ari-gold/)github.com
(https://en.wikipedia.org/wiki/Jeremy_Piven)github.com
(https://www.imdb.com/title/tt3661590/)github.com
 [2023-05-25 09:59 UTC] azqas45 at gmail dot com
That’s what I was looking for, what an info present here at this website, thank you admin! (https://www.mybkexperience.one/)github.com
 [2023-06-05 12:00 UTC] RobertBetts2294 at gmail dot com
The surrounding infrastructure/code in prod is fairly long and complex, so I'm not sure how much needs to get added in to reproduce the issue. But it's a run loop for an async job worker which performs a network request and then parses and stores the results in a database. Nothing too special. The code in question has been live for months without ever having an issue (https://www.myenvoyair.net/)github.com
 [2023-06-30 10:07 UTC] gthyhj322 at gmail dot com
That was so amazing.

(https://github.com)(https://www.marykayintouch.website/)
 [2024-01-03 05:53 UTC] youthteamconnect dot com at gmail dot com
This is a great post. I like this topic. I found many interesting things from this site. Thanks for posting this again

(https://github.com)(https://marykayintouch.pics/)
 [2024-01-05 14:50 UTC] marykayintouch53 at gmail dot com
(https://github.com)(https://marykayintouch.cloud/)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC