php - 如何调试和记录 PHP OPcache 问题

标签 php debugging opcache

我在 Windows 10 上使用 WAMP,运行 PHP 7.2 和 Apache 2.4

当我打开 OPcache 时,我正在加载的页面在 Chrome 中崩溃并出现以下错误:

ERR_CONNECTION_RESET

我检查了 php 错误日志和 Apache 错误日志,没有发现任何错误报告。我试图禁用 Xdebug,仍然是同样的崩溃并且日志中没有错误。 关闭 OPcache 或切换到 php 7.1 或更低版本可解决问题。

我到处寻找有关如何调试导致 OPcache 失败的原因(以及原因)的信息,因为关闭它不是解决方案,但找不到任何有用的信息(还检查了类似的 SO 问题,如 this one也没有解决方案),所以我向这里的专家寻求帮助,我相信这也会帮助其他人。

谢谢。

附言请注意,经过很长时间的手动试错后,我找到了 the file。在我的导致 OPcache 失败/崩溃的 php 应用程序中,并在 OPcache php.ini 配置中将该文件列入黑名单(也减少了它的大小工作正常,所以我怀疑问题是里面的实际代码),但我仍在寻找一个简单的无需检查服务器上的每个文件即可调试此类问题的方法。我也不知道为什么会失败,所以找到失败的原因将有助于向 OPcache 开发人员提交错误报告。

编辑: 添加 pastebin 链接需要将代码添加到问题中。这是 pastebin 文件的开头:

<?php

global $_LANGADM;
$_LANGADM = array();

$_LANGADM['AdminAddressesd3b206d196cd6be3a2764c1fb90b200f'] = 'Delete selected';
$_LANGADM['AdminAddressese25f0ecd41211b01c83e5fec41df4fe7'] = 'Delete selected items?';

长话短说

我正在寻找:

1) 一种轻松确定 OPcache 是导致脚本失败的扩展的方法,无需通过手动试错来检查每个扩展(打开/关闭它们直到找到失败的扩展)。

2) 轻松找到一种方式/日志,显示启用 OPcache 时哪个文件和原因失败。

用最简单的话来说——当 OPcache 失败时,我们如何知道何时、何地以及为什么失败,因为没有任何报告/日志就像大海捞针,尤其是当 Xdebug 似乎没有记录或输出任何东西时当 OPcache 因某种原因失败时。

再次感谢

最佳答案

1) A way to easily determine that OPcache is the extension that makes a script fail, without having to go through each extension and turn them on/off until finding the extension that fails.

您可以将以下内容添加到脚本中以暂时禁用 opcache。

ini_set('opcache.enable', 0);

2) Easily find a way/log that shows which file and the reason/s it fails when OPcache is enabled.

如果没有有关您尝试调试的应用程序的更多信息,这将变得更加困难。您可以先确保您的错误显示已打开。

ini_set('display_errors', 1); error_reporting(~0);

但是,如果这不起作用,我建议您使用 Xdebug 调试您的应用程序。

Xdebug's (remote) debugger allows you to examine data structure, interactively walk through your and debug your code (from https://xdebug.org/docs/remote).

关于php - 如何调试和记录 PHP OPcache 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52110859/

相关文章:

php - Laravel 5 Schedular 与 Indatus 调度程序

javascript - 表单提交两次(ajax 和 jquery)

php - Zend OPCache - opcache.enable_cli 1 还是 0?它有什么作用?

php - 在 php.ini 中禁用 opcache.enable 在 CentOS 上不起作用

php - Opcache 预加载并缺少 App_KernelProdContainer.preload.php

javascript - 将数据上传到数据库而不停止站点的加载

php - mysql php 语句

Xcode 和 ARC 调试问题(跳过 dealloc)

c++ - 在 Visual Studio 中调试多线程程序时出现 "Step over"

java - 在控制台输出中使用 println 正确排序运行时异常