|
How do you run this to make it segfault?
When running this on the command line in the following ways, I can't reproduce this:
XDEBUG_MODE=develop valgrind php /tmp/2349/bug02349.inc
And valgrind shows no warnings either. |
|
|
I'm pretty sure I've got the same error as lcarilla. I haven't been able to reduce it to an actually small example, but when there is an exception reading messages from RabbitMQ with Xdebug active, it gives a segfault (Symfony uses generators for this, that's why I believe we are talking about the same error).
I have prepared a minimal Symfony project to reproduce the issue: https://github.com/juanmcasanova/xdebug-2349
If you need anything else from me (or that I create a new issue), just let me know! |
|
|
Sorry, forgot to include my PHP version information:
PHP 8.3.21 (cli) (built: May 21 2025 23:17:35) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.21, Copyright (c) Zend Technologies
with Zend OPcache v8.3.21, Copyright (c), by Zend Technologies
with Xdebug v3.4.3, Copyright (c) 2002-2025, by Derick Rethans |
|
|
@Juancasanova: How do I run that Symfony project to reproduce? I know nothing about Symfony, and running the commands in the README still gives me errors:
2349$ php bin/console messenger:consume async -vv
[OK] Consuming messages from transport "async".
// The worker will automatically exit once it has received a stop signal via
// the messenger:stop-workers command.
// Quit the worker with CONTROL-C.
[critical] Error thrown while running command "messenger:consume async -vv". Message: "Could not connect to the AMQP server. Please verify the provided DSN."
In AmqpReceiver.php line 66:
[Symfony\Component\Messenger\Exception\TransportException]
Could not connect to the AMQP server. Please verify the provided DSN.
Exception trace:
at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/AmqpReceiver.php:66
Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceiver->getEnvelope() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/AmqpReceiver.php:47
Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceiver->getFromQueues() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/AmqpReceiver.php:41
Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceiver->get() at /tmp/2349/xdebug-2349/vendor/symfony/messenger/Worker.php:111
Symfony\Component\Messenger\Worker->run() at /tmp/2349/xdebug-2349/vendor/symfony/messenger/Command/ConsumeMessagesCommand.php:260
Symfony\Component\Messenger\Command\ConsumeMessagesCommand->execute() at /tmp/2349/xdebug-2349/vendor/symfony/console/Command/Command.php:279
Symfony\Component\Console\Command\Command->run() at /tmp/2349/xdebug-2349/vendor/symfony/console/Application.php:1094
Symfony\Component\Console\Application->doRunCommand() at /tmp/2349/xdebug-2349/vendor/symfony/framework-bundle/Console/Application.php:123
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /tmp/2349/xdebug-2349/vendor/symfony/console/Application.php:342
Symfony\Component\Console\Application->doRun() at /tmp/2349/xdebug-2349/vendor/symfony/framework-bundle/Console/Application.php:77
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /tmp/2349/xdebug-2349/vendor/symfony/console/Application.php:193
Symfony\Component\Console\Application->run() at /tmp/2349/xdebug-2349/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /tmp/2349/xdebug-2349/vendor/autoload_runtime.php:29
require_once() at /tmp/2349/xdebug-2349/bin/console:15
In Connection.php line 491:
[AMQPException]
Could not connect to the AMQP server. Please verify the provided DSN.
Exception trace:
at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/Connection.php:491
Symfony\Component\Messenger\Bridge\Amqp\Transport\Connection->channel() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/Connection.php:549
Symfony\Component\Messenger\Bridge\Amqp\Transport\Connection->clearWhenDisconnected() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/Connection.php:426
Symfony\Component\Messenger\Bridge\Amqp\Transport\Connection->get() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/AmqpReceiver.php:54
Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceiver->getEnvelope() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/AmqpReceiver.php:47
Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceiver->getFromQueues() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/AmqpReceiver.php:41
Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceiver->get() at /tmp/2349/xdebug-2349/vendor/symfony/messenger/Worker.php:111
Symfony\Component\Messenger\Worker->run() at /tmp/2349/xdebug-2349/vendor/symfony/messenger/Command/ConsumeMessagesCommand.php:260
Symfony\Component\Messenger\Command\ConsumeMessagesCommand->execute() at /tmp/2349/xdebug-2349/vendor/symfony/console/Command/Command.php:279
Symfony\Component\Console\Command\Command->run() at /tmp/2349/xdebug-2349/vendor/symfony/console/Application.php:1094
Symfony\Component\Console\Application->doRunCommand() at /tmp/2349/xdebug-2349/vendor/symfony/framework-bundle/Console/Application.php:123
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /tmp/2349/xdebug-2349/vendor/symfony/console/Application.php:342
Symfony\Component\Console\Application->doRun() at /tmp/2349/xdebug-2349/vendor/symfony/framework-bundle/Console/Application.php:77
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /tmp/2349/xdebug-2349/vendor/symfony/console/Application.php:193
Symfony\Component\Console\Application->run() at /tmp/2349/xdebug-2349/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /tmp/2349/xdebug-2349/vendor/autoload_runtime.php:29
require_once() at /tmp/2349/xdebug-2349/bin/console:15
In Connection.php line 489:
[AMQPConnectionException]
Socket error: could not connect to host, a socket error occurred
Exception trace:
at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/Connection.php:489
AMQPConnection->connect() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/Connection.php:489
Symfony\Component\Messenger\Bridge\Amqp\Transport\Connection->channel() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/Connection.php:549
Symfony\Component\Messenger\Bridge\Amqp\Transport\Connection->clearWhenDisconnected() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/Connection.php:426
Symfony\Component\Messenger\Bridge\Amqp\Transport\Connection->get() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/AmqpReceiver.php:54
Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceiver->getEnvelope() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/AmqpReceiver.php:47
Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceiver->getFromQueues() at /tmp/2349/xdebug-2349/vendor/symfony/amqp-messenger/Transport/AmqpReceiver.php:41
Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceiver->get() at /tmp/2349/xdebug-2349/vendor/symfony/messenger/Worker.php:111
Symfony\Component\Messenger\Worker->run() at /tmp/2349/xdebug-2349/vendor/symfony/messenger/Command/ConsumeMessagesCommand.php:260
Symfony\Component\Messenger\Command\ConsumeMessagesCommand->execute() at /tmp/2349/xdebug-2349/vendor/symfony/console/Command/Command.php:279
Symfony\Component\Console\Command\Command->run() at /tmp/2349/xdebug-2349/vendor/symfony/console/Application.php:1094
Symfony\Component\Console\Application->doRunCommand() at /tmp/2349/xdebug-2349/vendor/symfony/framework-bundle/Console/Application.php:123
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /tmp/2349/xdebug-2349/vendor/symfony/console/Application.php:342
Symfony\Component\Console\Application->doRun() at /tmp/2349/xdebug-2349/vendor/symfony/framework-bundle/Console/Application.php:77
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /tmp/2349/xdebug-2349/vendor/symfony/console/Application.php:193
Symfony\Component\Console\Application->run() at /tmp/2349/xdebug-2349/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /tmp/2349/xdebug-2349/vendor/autoload_runtime.php:29
require_once() at /tmp/2349/xdebug-2349/bin/console:15
messenger:consume [-l|--limit LIMIT] [-f|--failure-limit FAILURE-LIMIT] [-m|--memory-limit MEMORY-LIMIT] [-t|--time-limit TIME-LIMIT] [--sleep SLEEP] [-b|--bus BUS] [--queues QUEUES] [--no-reset] [--all] [--keepalive [KEEPALIVE]] [--] [<receivers>...]
|
|
|
I was able to create a reproducer for this - and probably also https://bugs.xdebug.org/view.php?id=2350 and https://bugs.xdebug.org/view.php?id=2352
Unfortunately it is not really minimal yet since it uses Twig but trying to extract the crashing code any further always failed to reproduce. But now it at least crashes reliably...
Since it was so hard to pin done the exact crashing conditions I put the code inside a reproducer repo that can simply be opened in vscode devcontainers / codespaces: https://github.com/acran/xdebug-2349-reproducer
The code example is
<code>
<?php
use Twig\Environment;
use Twig\Loader\ArrayLoader;
require_once DIR . '/vendor/autoload.php';
$loader = new ArrayLoader([
'test' => '{{ user.name }}',
]);
$twig = new Environment($loader);
class User {
public function getName() {
// throw an Exception while rendering
// in \Twig\Template::doDisplay()
throw new Exception();
}
}
$user = new User();
try {
// set a breakpoint on the following line and step over it
$twig->render('test', ['user' => $user]);
echo "we should never come here\n";
} catch (Throwable $e) {
echo "we should end up here due to the thrown Exception\n";
} finally {
echo "this should always be reached\n";
}
</code>
The crash only occurs when an Exception is thrown within Twig\Template::doDisplay() (https://github.com/twigphp/Twig/blob/285123877d4dd97dd7c11842ac5fb7e86e60d81d/src/Template.php#L526-L534) (which is implemented by a dynamically generated class for the rendered template).
It is called from Twig\Template::yield() (https://github.com/twigphp/Twig/blob/285123877d4dd97dd7c11842ac5fb7e86e60d81d/src/Template.php#L401-L403):
<code>
try {
yield from $this->doDisplay($context, $blocks);
} catch (Error $e) {
</code>
Both methods are generators which puts the Exception in the context of nested generators.
More things I noticed:
- the crash occurs only with xdebug 3.4.3, downgrading to 3.4.2 works fine
- reproducible with PHP 8.2, 8.3 and 8.4 (change the versions in Dockerfile to test it)
- crash only occurs if xdebug.mode includes 'develop'
|
|
|
Thanks, I'll see if this is enough info to reproduce this in the next few days, and then also hopefully fix it. |
|
|
https://github.com/xdebug/xdebug/pull/1020 |
|
|
https://github.com/xdebug/xdebug/pull/1021 replaces the previous one |
|
|
A fix for this has now been merged. It would be great if you could check out the latest code on GitHub (The xdebug_3_4 branch). If not, this will make it into a release probably tomorrow. |
|
|
Using current xdebug_3_4 branch crashes are no more reproducible with my small reproducer example as well with my affected full application. The PR seems to have fixed it.
Thank you very much! |
|