RFC: Error Backtraces v2 - #17056
Conversation
1559069 to
be75a57
Compare
|
Apologies for the additional notifications, there are understandably quite a lot of tests that trigger fatal errors. |
|
I really don't like the amount of changed files. The default for test runner should be to not display it IMHO. |
It is unfortunate; I have a similar feature I was working on that changed error output and the amount of tests it involved touching was really annoying, both to update tests and to review. |
|
Can you please add error_backtrace_recording=0 to |
I'll take that into consideration - I'm waiting on the RFC discussion and potential vote before making any further changes at this time. Please chime in there if you have any other thoughts on this proposal, I'd appreciate it! That said, I've kept the changes to a separate commit, which should allow people to review the first commit in isolation without needing to go through the changed tests. I don't really feel strongly here, however, so if people either want this to default to off (which is a voting option), or just to default to off for tests (which we could decide in the implementation), I'm fine with making the change once we've moved further along in the discussion. |
derickr
left a comment
There was a problem hiding this comment.
I'll add that I am also not in favour of changes to alllll the tests. I would also add, that the PHP project does not prefix their commit messages with feat: etc.
iluuu1994
left a comment
There was a problem hiding this comment.
Not a huge fan of the code churn. IMO, the stack trace should be avoided for compile errors, where the trace is really just noise.
|
Apologies for bumping this PR again - I'm going to look into backporting this internally as I assume the code won't change at this point - but any chance this could get merged sometime this week? |
|
Maybe @iluuu1994 or @dstogov still have comments, but I don't see problems anymore. |
dstogov
left a comment
There was a problem hiding this comment.
I don't like the RFC, but it's accepted and I don't see technical problems in the implementation.
|
Hey @dstogov, thanks for taking a look! If you don't like the RFC, would you mind elaborating on what about it you don't like, either privately at my email address, or here? I have some interest in thinking more about error handling and formatting, although I'm happy this RFC at least solves the initial problem I aimed to solve. I'll note that I shared some thoughts on changing how the error callback works in https://externals.io/message/126110#126121, but I didn't get any follow-up discussion to that. |
|
I just merged the latest master and added NEWS/UPGRADING. Will merge once the CI passes. |
|
Now merged. Don't forget to adjust the status in the Wiki. |
|
Thanks @TimWolla, and done. I appreciate everyone's feedback, and again, if you have additional thoughts on error handling, feel free to reach out to me. |
Since phpGH-17056, the result may return the backtrace array.
This became visible after phpGH-17056 was merged, but technically the lack of setting the opline is also present on lower branches. We set the opline to mirror the SAVE_OPLINE() from ZEND_INIT_STATIC_METHOD_CALL().
|
php.ini not updated |
This is a useful feature, but enabling it by default requires rewriting every PHPT file's output section. Since that would be a hellish diff to make and to review, I think the best option is unfortunately, another INI option. We can enable this for prod/dev recommended INIs, but make sure it's disabled for the test runner. This takes some inspiration from the discussion in phpGH-17056, which has similar problems to this PR.
This is a useful feature, but enabling it by default requires rewriting every PHPT file's output section. Since that would be a hellish diff to make and to review, I think the best option is unfortunately, another INI option. We can enable this for prod/dev recommended INIs, but make sure it's disabled for the test runner. This takes some inspiration from the discussion in phpGH-17056, which has similar problems to this PR.
This is a useful feature, but enabling it by default requires rewriting every PHPT file's output section. Since that would be a hellish diff to make and to review, I think the best option is unfortunately, another INI option. We can enable this for prod/dev recommended INIs, but make sure it's disabled for the test runner. This takes some inspiration from the discussion in phpGH-17056, which has similar problems to this PR.
This is a useful feature, but enabling it by default requires rewriting every PHPT file's output section. Since that would be a hellish diff to make and to review, I think the best option is unfortunately, another INI option. We can enable this for prod/dev recommended INIs, but make sure it's disabled for the test runner. This takes some inspiration from the discussion in phpGH-17056, which has similar problems to this PR.
see https://wiki.php.net/rfc/error_backtraces_v2 Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Since phpGH-17056, the result may return the backtrace array. Closes phpGH-17641
This became visible after phpGH-17056 was merged, but technically the lack of setting the opline is also present on lower branches. We set the opline to mirror the SAVE_OPLINE() from ZEND_INIT_STATIC_METHOD_CALL(). Closes phpGH-17732.
This pull request seeks to continue the work from #5642, but using an implementation more in line with what nikic suggested in https://externals.io/message/110302#113264:
The RFC will be at https://wiki.php.net/rfc/error_backtraces_v2.
I've created a new INI setting,
error_backtrace_recording, which users can set to an error mask to enable backtraces for those errors. It defaults toE_FATAL_ERRORS, which I've also exposed as a userland constant.Considering the default, any fatal error will now have a backtrace associated with it. For example, a script timeout will now look like:
This would have been useful to us very recently: we had an issue in production that presented as "Maximum execution time of X second exceeded" errors, and it was difficult for us to identity the underlying culprit. We eventually identified it as an infinite loop, which would have been incredibly obvious in a trace if it was available.
The implementation respects the
zend.exception_ignore_argsINI setting and the SensitiveParameter attributes, so users can ensure that sensitive arguments do not end up in the backtrace.I have some open questions about this implementation:
zend_startupresponsible for settingEG(error_reporting), and notexecutor_globals_ctor? I've done the same forEG(error_backtrace_recording)purely for consistency.zend_error_cb? If so, I could pass the backtrace as a nullable argument instead of setting an executor global.I've updated all tests that are now failing due to the stack trace in the second commit, to keep the diff reviewable.