Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 848a830

Browse filesBrowse files
bug #30327 [HttpKernel] Fix possible infinite loop of exceptions (enumag)
This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel] Fix possible infinite loop of exceptions | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | I ran into an [issue](php-enqueue/enqueue-dev#774) in the enqueue library which copied this part of code from Symfony. I'm now starting to understand what the problem is and it should most likely be fixed in Symfony as well. I didn't actually run into it in Symfony itself but it seems at least hypothetically possible. Imagine if [here](https://github.com/symfony/symfony/blob/8c3dc8254a508593aa0637445659e93e39d31dca/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php#L77) `$e` is somehow the same (===) as `$exception`. The code [below](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php#L82-L92) will then find the last exception in the `getPrevious()` chain and assigns `$exception` as the previous. However in the off chance that `$exception` is actually `$e` (the first exception in the chain) then it creates an infinite loop of exceptions which is not good for monolog and exception handlers. What do you think? Commits ------- 3447222 [HttpKernel] Fix possible infinite loop of exceptions
2 parents 7b4f4bf + 3447222 commit 848a830
Copy full SHA for 848a830

File tree

1 file changed

+3
-4
lines changed
Filter options

1 file changed

+3
-4
lines changed

‎src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ public function onKernelException(GetResponseForExceptionEvent $event)
5656
} catch (\Exception $e) {
5757
$this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', \get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()));
5858

59-
$wrapper = $e;
60-
61-
while ($prev = $wrapper->getPrevious()) {
59+
$prev = $e;
60+
do {
6261
if ($exception === $wrapper = $prev) {
6362
throw $e;
6463
}
65-
}
64+
} while ($prev = $wrapper->getPrevious());
6665

6766
$prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous');
6867
$prev->setAccessible(true);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.