8000 Typed property Symfony\Component\Cache\Adapter\TraceableAdapterEvent::$end must not be accessed before initialization · Issue #48910 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Typed property Symfony\Component\Cache\Adapter\TraceableAdapterEvent::$end must not be accessed before initialization #48910

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

Closed
Bilge opened this issue Jan 7, 2023 · 4 comments

Comments

@Bilge
Copy link
Contributor
Bilge commented Jan 7, 2023

Symfony version(s) affected

6.2.4

Description

When an exception is thrown in debug mode in the callback passed to Symfony\Contracts\Cache\CacheInterface::get(string $key, callable $callback), Symfony will end up masking the exception with its own as CacheDataCollector throws the following exception:

Typed property Symfony\Component\Cache\Adapter\TraceableAdapterEvent::$end must not be accessed before initialization in symfony\cache\DataCollector\CacheDataCollector.php on line 118.

$statistics[$name]['time'] += $call->end - $call->start;

How to reproduce

Probably something like the following should get it to trigger, although in my testing, it does not.

$cache->get(
    'foo',
    function (ItemInterface $item) {
        throw new \Exception;
    }
);

I am not sure what it is about my app in particular that triggers it, but the exception is actually thrown from a fiber, in case that matters. Here's a snapshot of $calls.

image

Possible Solution

No response

Additional Context

This does not happen on Symfony 5.4; the correct userland exception message and trace is shown, instead of one coming from Symfony's components.

@alamirault
Copy link
Contributor

I'm not able to reproduce either.

Can you confirm that TraceableAdapterEvent is built by this adapter ? Or is it another ?

public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed

@Bilge
Copy link
Contributor Author
Bilge commented Jan 8, 2023

@alamirault Yes, a breakpoint shows it does get created by that adapter. It runs $value = $this->pool->get($key, $callback, $beta, $metadata);, but despite failing at that call, the finally block never runs, perhaps because the exception is thrown in a fiber? I'm not really sure. Here's the full stack trace.

CacheDataCollector.php:118, Symfony\Component\Cache\DataCollector\CacheDataCollector->calculateStatistics()
CacheDataCollector.php:48, Symfony\Component\Cache\DataCollector\CacheDataCollector->collect()
Profiler.php:156, Symfony\Component\HttpKernel\Profiler\Profiler->collect()
ProfilerListener.php:108, Symfony\Component\HttpKernel\EventListener\ProfilerListener->onKernelResponse()
WrappedListener.php:115, Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke()
EventDispatcher.php:206, Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
EventDispatcher.php:56, Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
TraceableEventDispatcher.php:127, Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch()
HttpKernel.php:196, Symfony\Component\HttpKernel\HttpKernel->filterResponse()
HttpKernel.php:184, Symfony\Component\HttpKernel\HttpKernel->handleRaw()
HttpKernel.php:74, Symfony\Component\HttpKernel\HttpKernel->handle()
ErrorListener.php:90, Symfony\Component\HttpKernel\EventListener\ErrorListener->onKernelException()
WrappedListener.php:115, Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke()
EventDispatcher.php:206, Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
EventDispatcher.php:56, Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
TraceableEventDispatcher.php:127, Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch()
HttpKernel.php:221, Symfony\Component\HttpKernel\HttpKernel->handleThrowable()
HttpKernel.php:114, Symfony\Component\HttpKernel\HttpKernel->terminateWithException()
DebugHandlersListener.php:125, Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::Symfony\Component\HttpKernel\EventListener\{closure:C:\Users\Bilge\Documents\PhpstormProjects\Club 250\vendor\symfony\http-kernel\EventListener\DebugHandlersListener.php:119-126}()
ErrorHandler.php:538, Symfony\Component\ErrorHandler\ErrorHandler->handleException()
ErrorHandler.php:628, Symfony\Component\ErrorHandler\ErrorHandler::handleFatalError()
ErrorHandler.php:0, Fiber->start()
AbstractDriver.php:83, Revolt\EventLoop\Internal\AbstractDriver->Revolt\EventLoop\Internal\{closure:C:\Users\Bilge\Documents\PhpstormProjects\Club 250\vendor\revolt\event-loop\src\EventLoop\Internal\AbstractDriver.php:78-84}()
DriverSuspension.php:95, Revolt\EventLoop\Internal\DriverSuspension->suspend()
Future.php:251, Amp\Future->await()
ImportConnector.php:76, ScriptFUSION\Porter\Connector\ImportConnector->ScriptFUSION\Porter\Connector\{closure:C:\Users\Bilge\Documents\PhpstormProjects\Club 250\vendor\scriptfusion\porter\src\Connector\ImportConnector.php:76-76}()
retry.php:29, ScriptFUSION\Retry\retry()
ImportConnector.php:77, ScriptFUSION\Porter\Connector\ImportConnector->fetch()
GetSteam250Menu.php:25, ScriptFUSION\Club250\Esi\GetSteam250Menu->fetch()
RecordCollection.php:33, Generator->valid()
RecordCollection.php:33, ScriptFUSION\Porter\Collection\RecordCollection->valid()
PorterRecords.php:15, ScriptFUSION\Porter\Collection\PorterRecords->__construct()
Porter.php:148, ScriptFUSION\Porter\Porter->createPorterRecords()
Porter.php:114, ScriptFUSION\Porter\Porter->fetch()
Porter.php:76, ScriptFUSION\Porter\Porter->importOne()
EsiService.php:34, ScriptFUSION\Club250\Esi\EsiService->ScriptFUSION\Club250\Esi\{closure:C:\Users\Bilge\Documents\PhpstormProjects\Club 250\src\Esi\EsiService.php:28-37}()
TraceableAdapter.php:48, Symfony\Component\Cache\Adapter\TraceableAdapter->Symfony\Component\Cache\Adapter\{closure:C:\Users\Bilge\Documents\PhpstormProjects\Club 250\vendor\symfony\cache\Adapter\TraceableAdapter.php:45-49}()
LockRegistry.php:96, Symfony\Component\Cache\LockRegistry::compute()
ContractsTrait.php:106, Symfony\Component\Cache\Adapter\AbstractAdapter->Symfony\Component\Cache\Traits\{closure:C:\Users\Bilge\Documents\PhpstormProjects\Club 250\vendor\symfony\cache\Traits\ContractsTrait.php:87-113}()
CacheTrait.php:64, Symfony\Component\Cache\Adapter\AbstractAdapter->contractsGet()
ContractsTrait.php:113, Symfony\Component\Cache\Adapter\AbstractAdapter->doGet()
CacheTrait.php:30, Symfony\Component\Cache\Adapter\AbstractAdapter->get()
TraceableCacheAdapterForV3.php:48, Sentry\SentryBundle\Tracing\Cache\TraceableCacheAdapterForV3->Sentry\SentryBundle\Tracing\Cache\{closure:C:\Users\Bilge\Documents\PhpstormProjects\Club 250\vendor\sentry\sentry-symfony\src\Tracing\Cache\TraceableCacheAdapterForV3.php:43-49}()
TraceableCacheAdapterTrait.php:183, Sentry\SentryBundle\Tracing\Cache\TraceableCacheAdapterForV3->traceFunction()
TraceableCacheAdapterForV3.php:49, Sentry\SentryBundle\Tracing\Cache\TraceableCacheAdapterForV3->get()
TraceableAdapter.php:53, Symfony\Component\Cache\Adapter\TraceableAdapter->get()
EsiService.php:37, ScriptFUSION\Club250\Esi\EsiService->fetchMenu()
EsiController.php:16, ScriptFUSION\Club250\Esi\EsiController->getMenu()
HttpKernel.php:163, Symfony\Component\HttpKernel\HttpKernel->handleRaw()
HttpKernel.php:74, Symfony\Component\HttpKernel\HttpKernel->handle()
SubRequestHandler.php:86, Symfony\Component\HttpKernel\HttpCache\SubRequestHandler::handle()
InlineFragmentRenderer.php:78, Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer->render()
AbstractSurrogateFragmentRenderer.php:66, Symfony\Component\HttpKernel\Fragment\AbstractSurrogateFragmentRenderer->render()
FragmentHandler.php:81, Symfony\Component\HttpKernel\Fragment\FragmentHandler->render()
LazyLoadingFragmentHandler.php:47, Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler->render()
HttpKernelRuntime.php:54, Symfony\Bridge\Twig\Extension\HttpKernelRuntime->renderFragmentStrategy()
790ec32dfb74a2fc43094f2d3b08657b.php:129, __TwigTemplate_147a5b18f69bd56814b19b28b8808b6b->block_body()
Template.php:171, Twig\Template->displayBlock()
6581ad764002d39ce8440a27a7bcfdcf.php:97, __TwigTemplate_5f939158a7c3bcbe721337787f88813f->doDisplay()
Template.php:394, Twig\Template->displayWithErrorHandling()
Template.php:367, Twig\Template->display()
790ec32dfb74a2fc43094f2d3b08657b.php:53, __TwigTemplate_147a5b18f69bd56814b19b28b8808b6b->doDisplay()
Template.php:394, Twig\Template->displayWithErrorHandling()
Template.php:367, Twig\Template->display()
317a13623e96e87e6e37dc77ae2c8c57.php:53, __TwigTemplate_15153d96513e89fe2de01fe7c77489dd->doDisplay()
Template.php:394, Twig\Template->displayWithErrorHandling()
Template.php:367, Twig\Template->display()
Template.php:379, Twig\Template->render()
TemplateWrapper.php:40, Twig\TemplateWrapper->render()
Environment.php:280, Twig\Environment->render()
AbstractController.php:242, Symfony\Bundle\FrameworkBundle\Controller\AbstractController->renderView()
AbstractController.php:253, Symfony\Bundle\FrameworkBundle\Controller\AbstractController->render()
MailSubscribeAction.php:34, ScriptFUSION\Club250\Mail\MailSubscribeAction->__invoke()
HttpKernel.php:163, Symfony\Component\HttpKernel\HttpKernel->handleRaw()
HttpKernel.php:74, Symfony\Component\HttpKernel\HttpKernel->handle()
Kernel.php:184, Symfony\Component\HttpKernel\Kernel->handle()
index.php:31, {main}()

We're also 3 requests deep by this point, if you count the number of HttpKernel->handle() calls, in case that matters.

@xabbuh
Copy link
Member
xabbuh commented Jan 10, 2023

It runs $value = $this->pool->get($key, $callback, $beta, $metadata);, but despite failing at that call, the finally block never runs, perhaps because the exception is thrown in a fiber? I'm not really sure. Here's the full stack trace.

might be worth reporting this to PHP itself instead, at least this does not look like the expected behaviour to me

@andriusvo
Copy link

Appeared to me also. Noticed, that this happens then PHP memory is limited.

@derrabus derrabus added the Cache label Jan 19, 2023
nicolas-grekas added a commit that referenced this issue Jan 20, 2023
…ns (nicolas-grekas)

This PR was merged into the 5.4 branch.

Discussion
----------

[Cache] fix collecting cache stats when nesting computations

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #48910
| License       | MIT
| Doc PR        | -

Commits
-------

52a0e43 [Cache] fix collecting cache stats when nesting computations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
0