Skip to content

[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

Merged
merged 1 commit into from
Jan 13, 2018

Conversation

nicolas-grekas
Copy link
Member

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 -

Copy link
Contributor

@dbu dbu left a 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.

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Jan 11, 2018

this could have the new side effect

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.

@dbu
Copy link
Contributor

dbu commented Jan 11, 2018

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.

@nicolas-grekas nicolas-grekas mentioned this pull request Jan 12, 2018
Copy link
Member

@Nyholm Nyholm left a 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;
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 :)

@fabpot
Copy link
Member

fabpot commented Jan 13, 2018

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 5f397f8 into symfony:2.7 Jan 13, 2018
fabpot added a commit that referenced this pull request Jan 13, 2018
…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
@nicolas-grekas nicolas-grekas deleted the debug-loop branch February 19, 2018 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants