Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[WIP] [Debug] Avoid fatal handler loops#26559

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@Jean85
Copy link
Contributor

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?no
Fixed tickets#26438
LicenseMIT

This PR starts to try and solve#26438. For now it's just a WIP with the reproducing test case.

The bug is present when:

  • a third party error handler (like Sentry) is installed
  • a fatal in thrown under PHP 7

The third party error/exception handlers remember the previous handler, and call them when their work is finished. But Symfony's handler has this piece of code:

while (!is_array($handler) || !$handler[0]instanceof self) {
$handler =set_exception_handler('var_dump');
restore_exception_handler();
if (!$handler) {
break;
}
restore_exception_handler();
if ($handler !==$previousHandler) {
array_unshift($handlers,$handler);
$previousHandler =$handler;
}elseif (0 === --$sameHandlerLimit) {
$handler =null;
break;
}
}
foreach ($handlersas$h) {
set_exception_handler($h);
}

Citing@alcohol from#26438:

it looks like it is trying to find itself (or an instance of) in the stack of exception handlers that may or may not have been registered. It does this by restoring previous error handlers, and looking at what gets restored. Once it finds itself (or there simply arent any), it "restores" the previous stack of error handlers by reassigning them in order, and proceeds to the setExceptionHandler step, where the $handler should be an instance of itself, and $h is whatever what was last added to the stack of error handlers.

This operation creates a loop because the handler is altering the order of exception handlers, generating a loop: Symfony's handler is normally registered first by the FrameworkBundle, so it's putting himself as the last one registered with that.

Pinging@nicolas-grekas since he seems to have wrote a great part of the ErrorHandler.

istepaniuk reacted with thumbs up emoji
@alcohol
Copy link
Contributor

Just to clarify, itlooks like that, but I have no real idea because the code is very non-descriptive. Breaking the code up into smaller methods with clear intent might help resolve the bug itself more easily :-)

@nicolas-grekasnicolas-grekas added this to the2.7 milestoneMar 16, 2018
@Jean85
Copy link
ContributorAuthor

Closing this in favor of#26568 +nicolas-grekas#14

@Jean85Jean85 closed thisMar 16, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

4 participants

@Jean85@alcohol@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp