sentry-php: Capturing E_ERROR fatal errors broken on PHP 7

As commented by @mfb on #514:

What are you all doing to capture fatal PHP errors, such as allowed memory size exhausted? To capture this fatal error successfully, I had to comment out the return FALSE; in shouldCaptureFatalError():

if (PHP_VERSION_ID >= 70000 && $type === E_ERROR) {
  // return false;
}

sample code:

<?php
include '../vendor/autoload.php';
$client = new Raven_Client('...');
$client->install();
while (TRUE) {
  $a[] = 11111111111;
}

It seems like this does prevent those errors from being reporting, however removing that seems to bring us back to the original issue causing 2 reports for the same error, likely caused by https://github.com/getsentry/sentry-php/blob/25a2134ad9461e375baa22fe1e186796edab60a9/lib/Raven/ErrorHandler.php#L84 which causes the following error in my PHP 7.2 installation:

Parse error: syntax error, unexpected '}' in /private/var/www/sentry-php/error.php on line 5

Fatal error: Exception thrown without a stack frame in Unknown on line 0

Which are both reported, which is ofcourse incorrect.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 48 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I’m currently experiencing a strange issue with this too: using the Symfony integration, when a fatal (like a type error) is thrown, the actual behavior of the client creates a loop that does capture the exception but not the fatal, which “continues” and re-captures it again as an exception, generating a loop and creating thousands of identical events.

For reasons that hours of debugging couldn’t explain yet, FatalThrowableError triggers a runaway only when the NewRelic exception handler was installed by their extension first. Stack looks like (newer frame last)

  • Raven_ErrorHandler->handleException
  • Symfony\Component\Debug\ErrorHandler->handleException
  • newrelic_exception_handler
  • Symfony\Component\Debug\ErrorHandler->handleFatalError
  • Symfony\Component\Debug\ErrorHandler->handleException
  • Raven_ErrorHandler->handleException
  • Symfony\Component\Debug\ErrorHandler->handleException
  • Raven_ErrorHandler->handleException
  • (loops last two until FPM dies, flooding sentry with errors)

Is this the same issue?

(sentry/sentry 1.8.2, sentry/sentry-symfony 0.8.7)

It seems that https://github.com/symfony/symfony/pull/26568 fixes the issue, yay! 🎉

@Jean85 I’d like to throw in the fact that we’re not using the New Relic extension and are still experiencing many duplicate events being logged when encountering a FatalErrorException. For example, on a production server that was missing some cache:

Symfony\Component\Debug\Exception\FatalErrorException
Compile Error: require(): Failed opening required '/var/www/app/example/20180219101435/var/cache/prod/doctrine/orm/Proxies/__CG__AppBundleEntityExample.php' (include_path='.:/usr/share/php')

This exception would be captured between 10-20 times in 1 second.

  • PHP 7.1 (FPM)
  • sentry 1.8.3
  • sentry-symfony 2.0.1
  • symfony 3.4.4

I’m currently not sure how this should be fixed. I need to find time to investigate this further, because I do not know the full extent of this problem.

It seems that the combination that triggers this issue is

  • PHP 7.x
  • Sentry Client
  • Sentry bundle
  • NewRelic ext

Is this right?

@Jean85 I haven’t seen that on sentry-php alone. So should be a bug report on sentry-symfony?