Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Debug] prevent infinite loop with faulty exception handlers #25755

Merged
merged 1 commit into from Jan 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Symfony/Component/Debug/ErrorHandler.php
Expand Up @@ -561,6 +561,8 @@ public static function handleFatalError(array $error = null)

$handler = self::$reservedMemory = null;
$handlers = array();
$previousHandler = null;
$sameHandlerLimit = 10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 10 and not 11? Or 9?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can update to 9 if you prefer :) any other number ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe, You maybe had a thought about why you choose 10. =)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really :) 3 looked too low, 30 too high, 10 was in the middle :)


while (!is_array($handler) || !$handler[0] instanceof self) {
$handler = set_exception_handler('var_dump');
Expand All @@ -570,7 +572,14 @@ public static function handleFatalError(array $error = null)
break;
}
restore_exception_handler();
array_unshift($handlers, $handler);

if ($handler !== $previousHandler) {
array_unshift($handlers, $handler);
$previousHandler = $handler;
} elseif (0 === --$sameHandlerLimit) {
$handler = null;
break;
}
}
foreach ($handlers as $h) {
set_exception_handler($h);
Expand Down