You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Infinite loop when handling an exception (critical bug in my opinion) #774
I'm using the Symfony bundle. I start my consumer using bin/console enqueue/consume and sure enough it works just fine.
However if one of the consumed messages causes an exception, the consumer freezes without even writing anything to console or log - the exception is nowhere to be seen.
I used xdebug to find out what caused it and I believe the reason is that Symfony/Console runs into an infinite loop while trying to print the exception.
The reason why that happens is this code in your bundle:
$prev = new \ReflectionProperty('Exception', 'previous');
$prev->setAccessible(true);
$prev->setValue($wrapper, $exception);
}
It effectively creates a pair of exceptions where each has set the other one as the previous:
$e->getPrevious()->getPrevious() === $e// true
(or a longer chain of exceptions where the last one has the first one as previous - still effectively a cycle of exceptions)
I don't quite understand what is the idea behind this but obviously when an error handler tries to dump the exception chain this causes an infinite loop because ->getPrevious() never returns null.
Can you explain what the code in QueueConsumer::onProcessorException() is supposed to do? I'm quite sure this isn't intentional. When I remove the code I linked above, everything works as expected.
@makasim No it doesn't. I'm using v0.9.7 which already has this fix.
Maybe the condition there is supposed to be if ($exception !== $e) {? Because that's what happened in my case - $exception and $e are one and the same ($exception was rethrown here and then caught as $e) while $wrapper is different.
Also ping @DamienHarper - as the author of #725 you might have an idea.
@enumag Sorry I couldn't reply earlier, #725 helped me fix some issues I was experiencing at that time. Recently, I faced again some infinite loops, caused by those self-referencing exceptions, making some of my commands crash again. Though I hadn't enough time to investigate more.
So thanks for the fix.
Activity
enumag commentedon Feb 21, 2019
Ping @nicolas-grekas. You're the original author of this code in Symfony. What on earth is the reason to create an infinite loop of exceptions?
makasim commentedon Feb 21, 2019
As far as I understand this #725 fixes the issue. Could you check?
enumag commentedon Feb 21, 2019
@makasim No it doesn't. I'm using v0.9.7 which already has this fix.
Maybe the condition there is supposed to be
if ($exception !== $e) {? Because that's what happened in my case -$exceptionand$eare one and the same ($exceptionwas rethrown here and then caught as$e) while$wrapperis different.Also ping @DamienHarper - as the author of #725 you might have an idea.
DamienHarper commentedon Feb 21, 2019
@enumag Sorry I couldn't reply earlier, #725 helped me fix some issues I was experiencing at that time. Recently, I faced again some infinite loops, caused by those self-referencing exceptions, making some of my commands crash again. Though I hadn't enough time to investigate more.
So thanks for the fix.
bug #30327 [HttpKernel] Fix possible infinite loop of exceptions (enu…