-
Notifications
You must be signed in to change notification settings - Fork 63
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
fix(agent): Fix error reporting when EH_THROW is enabled #876
Conversation
/* * For a the following error codes: * E_WARNING || E_CORE_WARNING || E_COMPILE_WARNING || E_USER_WARNING * PHP triggers an exception if EH_THROW is toggled on and then immediately * returns after throwing the exception. See for more info: * https://github.com/php/php-src/blob/master/main/main.c In that case, we * should not handle it, but we should exist and let the exception handler * deal with it; otherwise, we could record an error even if an exception is * caught. */
|
/* * For a the following error codes: * E_WARNING || E_CORE_WARNING || E_COMPILE_WARNING || E_USER_WARNING * PHP triggers an exception if EH_THROW is toggled on and then immediately * returns after throwing the exception. See for more info: * https://github.com/php/php-src/blob/master/main/main.c In that case, we * should not handle it, but we should exist and let the exception handler * deal with it; otherwise, we could record an error even if an exception is * caught. */
7d8b174
to
0db7169
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #876 +/- ##
=======================================
Coverage 78.76% 78.76%
=======================================
Files 193 193
Lines 27125 27127 +2
=======================================
+ Hits 21365 21367 +2
Misses 5760 5760
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Co-authored-by: ZNeumann <[email protected]>
tests/integration/errors/test_EH_THROW_errors_caught_exception.php
Outdated
Show resolved
Hide resolved
tests/integration/errors/test_EH_THROW_errors_uncaught_exception.php
Outdated
Show resolved
Hide resolved
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'd like to know the answer to this question before I approve.
Co-authored-by: Michal Nowacki <[email protected]>
….php Co-authored-by: Michal Nowacki <[email protected]>
…on.php Co-authored-by: Michal Nowacki <[email protected]>
tests/integration/errors/test_EH_THROW_errors_caught_exception.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Michal Nowacki <[email protected]>
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.
Nice find!
This PR
1)checks if EH_THROW(which signals to PHP to throw an exception from the error) is toggled and if so does not record an error because if uncaught it will be handled by the exception handler and if caught there's no need to record it.
2) add tests to verify fix
More details:
/*
In the case where a php E_WARNING error was triggered. We intercept the error from PHP and record it then pass execution back to PHP.
But, for instance, in the particular case that deals with a filehandling which toggles EH_THROW on here: https://github.com/php/php-src/blob/master/ext/fileinfo/fileinfo.c#L176
PHP then handles the error but for a certain number of error codes, PHP triggers an exception if EH_THROW is toggled on: https://github.com/php/php-src/blob/master/main/main.c#L1254C1-L1259C24
and then immediately returns after throwing the exception.
This leads to the case in the issue where the exception that was triggered is caught, but we recorded the error....