-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Debug] prevent infinite loop with faulty exception handlers #25755
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
Conversation
nicolas-grekas
commented
Jan 10, 2018
Q | A |
---|---|
Branch? | 2.7 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #25743 |
License | MIT |
Doc PR | - |
4a8a18e
to
82dcb11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am a little bit worried if this could have the new side effect to mess with a badly done handler that is registered more than once and later expect itself to be registered more than once. something like (hyper simplified of course)
function doStuff($repeat = true)
{
set_exception_handler('stuff');
doStuff(false);
restore_exception_handler();
}
i think i would rather add all handlers to the array. if its the weird newrelic thing or something else messing with the built-in restore logic, it very likely is the last thing and it does not hurt to duplicate it.
82dcb11
to
5f397f8
Compare
it cannot: the code example you give is not affected at all: the fatal error handler is called as a shutdown function, never between your lines. |
i guess you are right. if shutdown is triggered while in the inner part, the end of the doStuff method won't be executed anyways. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this PR in production an it solves my problems.
@@ -561,6 +561,8 @@ public static function handleFatalError(array $error = null) | |||
|
|||
$handler = self::$reservedMemory = null; | |||
$handlers = array(); | |||
$previousHandler = null; | |||
$sameHandlerLimit = 10; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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. =)
There was a problem hiding this comment.
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 :)
Thank you @nicolas-grekas. |
…rs (nicolas-grekas) This PR was merged into the 2.7 branch. Discussion ---------- [Debug] prevent infinite loop with faulty exception handlers | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25743 | License | MIT | Doc PR | - Commits ------- 5f397f8 [Debug] prevent infinite loop with faulty exception handlers