如何跟踪“在第0行的Unknown中没有堆栈帧而引发的异常"?在PHP中? [英] How do I track down an "Exception thrown without a stack frame in Unknown on line 0" in PHP?

查看:79
本文介绍了如何跟踪“在第0行的Unknown中没有堆栈帧而引发的异常"?在PHP中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP开发大型(继承)代码库,并且错误Exception thrown without a stack frame in Unknown on line 0已经开始在每个页面的底部显示.我了解错误的含义:异常正在某个地方抛出,无法抛出.我什至设法对其进行了跟踪-它是在调用关闭函数的过程中发生的.

I'm working on a large (inherited) codebase in PHP, and the error Exception thrown without a stack frame in Unknown on line 0 has started showing up at the bottom of every page. I understand what the error means: an exception is getting thrown someplace it can't be thrown. I've even managed to track it down somewhat—it's happening during the time shutdown functions are being called.

我已经登录了所有在register_shutdown_function中注册的功能,并且在所有这些功能中都没有发生.不幸的是,我似乎无法获得更多的信息.我知道最后一次成功调用的关闭函数是什么,但是我不知道在那和错误发生之间将执行什么代码.我什至不知道PHP机器的哪个部分正在调用最后一个关闭函数.可能与日志记录框架或会话框架有关,或者与之有关的事情有六种.

I've put logging in all the functions which get registered with register_shutdown_function, and it's not happening in any of those. Unfortunately, I can't seem to get any more information than that; I know what the last shutdown function to get called successfully is, but I have no idea what code gets executed between that and the point where the error happens. I don't even know what part of the PHP machinery is calling that last shutdown function. It might be something with the logging framework, or the session framework, or anything of a half-dozen things.

有人知道如何查明发生错误的地方吗?

Does anyone know how to pinpoint where the error is occurring?

推荐答案

这可能在没有堆栈框架的析构函数和异常处理程序中发生.但是,由于该消息非常有帮助,因此您唯一的选择是尝试使用echo查找错误(甚至可能是ob_end_flush()).可能是析构函数正在引发异常,或者正在调用引发异常的函数.找到越野车功能后,请在异常抛出部分周围添加try ... catch.

This can happen in destructors and exception handlers which don't have a stack frame. But since the message is so very helpful, your only option is to try to use echo to find the bug (and maybe ob_end_flush()). It may be that a destructor is throwing an exception, or is calling a function that throws an exception. Once you've located the buggy function, add a try...catch around the exception throwing part.

请注意,如果您的框架使用自己的错误处理,则必须关闭PHP配置中的警告和注意事项.特别是如果您有类似 ErrorException 之类的东西,因为它将警告变成异常

Note that if your framework uses its own error handling, you have to turn off warnings and notices in the PHP configuration. Especially if you have something like ErrorException, since it turns warnings into exceptions.

这篇关于如何跟踪“在第0行的Unknown中没有堆栈帧而引发的异常"?在PHP中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆