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?
[25-Sep-2025 16:36:46] WARNING: [pool www] child 1195 exited on signal 11 (SIGSEGV) after 67.622459 seconds from startgdb) to check what happens when the process dies. I.e. for me it was some extension for PHP I had. Look forhow to debug a segfaulton the net to learn more. Good luck!