0

I'm experiencing a strange debugging issue with my Symfony web application where Xdebug causes a crash, but manually evaluating the same code works fine.

Problem Description

When debugging my Symfony application with Xdebug in PhpStorm, the application crashes when execution reaches var/cache/dev/ContainerJCxBVLf/EntityManager_9a5be93.php at line 225 (specifically at the getRepository() call).

However, when I manually evaluate $this->getRepository(); in the PhpStorm Debug Evaluator at the exact same breakpoint in Symfony\Bridge\Doctrine\Security\User\EntityUserProvider->refreshUser(), it executes successfully and the application continues normally.

Stack Trace

EntityManager_9a5be93.php:225, ContainerJCxBVLf\EntityManager_9a5be93->getRepository()
EntityUserProvider.php:139, Symfony\Bridge\Doctrine\Security\User\EntityUserProvider->getRepository()
EntityUserProvider.php:84, Symfony\Bridge\Doctrine\Security\User\EntityUserProvider->refreshUser()
ContextListener.php:216, Symfony\Component\Security\Http\Firewall\ContextListener->refreshUser()
ContextListener.php:131, Symfony\Component\Security\Http\Firewall\ContextListener->authenticate()
WrappedLazyListener.php:49, Symfony\Bundle\SecurityBundle\Debug\WrappedLazyListener->authenticate()
AbstractListener.php:26, Symfony\Component\Security\Http\Firewall\AbstractListener->__invoke()
TraceableFirewallListener.php:62, Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener->callListeners()
Firewall.php:86, Symfony\Component\Security\Http\Firewall->onKernelRequest()
WrappedListener.php:117, Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke()
EventDispatcher.php:230, Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
EventDispatcher.php:59, Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
TraceableEventDispatcher.php:151, Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch()
HttpKernel.php:133, Symfony\Component\HttpKernel\HttpKernel->handleRaw()
HttpKernel.php:79, Symfony\Component\HttpKernel\HttpKernel->handle()
Kernel.php:195, Symfony\Component\HttpKernel\Kernel->handle()
index.php:78, {main}()

Suspicious Code in Generated Proxy

I noticed that the generated cache file EntityManager_9a5be93.php appears to have a potential issue. The variable $valueHolder68094 is used without being defined in the local scope:

<?php
namespace ContainerJCxBVLf;
include_once \dirname(__DIR__, 4).'/vendor/doctrine/persistence/src/Persistence/ObjectManager.php';
include_once \dirname(__DIR__, 4).'/vendor/doctrine/orm/src/EntityManagerInterface.php';
include_once \dirname(__DIR__, 4).'/vendor/doctrine/orm/src/EntityManager.php';

class EntityManager_9a5be93 extends \Doctrine\ORM\EntityManager implements \ProxyManager\Proxy\VirtualProxyInterface
{
    /**
     * @var \Doctrine\ORM\EntityManager|null wrapped object, if the proxy is initialized
     */
    private $valueHolder68094 = null;

    /**
     * @var \Closure|null initializer responsible for generating the wrapped object
     */
    private $initializerd5058 = null;

    /**
     * @var bool[] map of public properties of the parent class
     */
    private static $publicProperties034fb = [

    ];

    // ...

    public function getRepository($entityName)
    {
        $this->initializerd5058 && ($this->initializerd5058->__invoke($valueHolder68094, $this, 'getRepository', array('entityName' => $entityName), $this->initializerd5058) || 1) && $this->valueHolder68094 = $valueHolder68094;

        return $this->valueHolder68094->getRepository($entityName);
    }

    // ...
}

Notice that in each method, $valueHolder68094 is passed to the initializer closure by reference, but it's not defined in the method's local scope.

Environment

  • PHP Version: 8.1.33
  • Xdebug Version: 3.4.5
  • Symfony Components: v5.2.x
    • symfony/cache: v5.2.0
    • doctrine/orm: 2.20.6
    • doctrine/doctrine-bundle: 2.7.0

What I've tried

  • Clearing the Symfony cache (the whole cache folder)
  • Manually evaluating the code in the Debug Evaluator (which works)

Question

Why does the Symfony application crash during Xdebug debugging at the EntityManager proxy's getRepository() call, but executing the same method manually in the Debug Evaluator works fine? Is this a known issue with proxy generation, Xdebug compatibility, or a configuration problem?

5
  • I can't tell you exactly what happens, but I can confirm you that, while generally Xdebug is robust and not too invasive (does not modify PHP's behaviour), in a few cases having it active makes PHP totally unpredictable. Although on an older versions of PHP than you (5.6 then 7.2), I have already experienced exactly what you describe; as well as a Symfony cache warmup that took literally 25 minutes with Xdebug (and a few seconds or dozens without it). Commented Sep 19 at 19:58
  • Wdym „a crash?” Commented Sep 20 at 19:35
  • @MikeDoe the debugger suddenly stops and I get a 504 from Nginx. If I set a breakpoint to the line it stops there and in the next step it also stops. I also could not find any error logs Commented Sep 22 at 7:54
  • @MikeDoe actually in the php8.1-fpm log i get a [25-Sep-2025 16:36:46] WARNING: [pool www] child 1195 exited on signal 11 (SIGSEGV) after 67.622459 seconds from start Commented Sep 25 at 14:38
  • 1
    It's a segfault, don't expect logs since the process dies. Instead you should debug the php-fpm process with a debugger (like gdb) to check what happens when the process dies. I.e. for me it was some extension for PHP I had. Look for how to debug a segfault on the net to learn more. Good luck! Commented Sep 27 at 9:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.