10

I am using WAMP on Windows 10, running PHP 7.2 with Apache 2.4

When I am turning on OPcache, a page I am loading crashes with the following error in Chrome:

ERR_CONNECTION_RESET

I checked the php error log and Apache error log and could not find any error reported. I tried to disable Xdebug, still same crash and no errors in the logs. Turning off OPcache or switching to php 7.1 or below resolves the issue.

I was looking everywhere for some information on how to debug what causes OPcache to fail (and the reason) as turning it off is not a solution, but couldn't find anything helpful (also checked similar SO questions like this one which also has no resolution), so I am reaching out to the experts here for assistance, which I am sure will also help others.

Thank you.

P.S. Note that after a very long manual trial and error I was able to find the file in my php application that was causing OPcache to fail/crash and blacklisted that file in OPcache php.ini configuration (also reducing its size worked fine, so I doubt the problem was the actual code inside), but I am still looking for an easy way to debug such issues without having to go through & check each file on a server. I also don't know why it fails, so finding the cause for the failure will help file bug reports to the OPcache developers.

EDIT: Adding a pastebin link requires code to be added to the question. Here is the beginning of the pastebin file:

<?php

global $_LANGADM;
$_LANGADM = array();

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

TL;DR

I am looking for:

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

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

In simplest words - how can we know when, where and why OPcache fails when it fails, as without any reports/logs it's like searching for a needle in a haystack, especially when even Xdebug seems to be not logging or outputing anything when OPcache fails, for some reason.

Thanks again

Nikita 웃
  • 2,042
  • 20
  • 45
  • Can you show the file that caused the failure? – Barmar Aug 31 '18 at 07:52
  • If you have a script that is causing the OpCache issue then show it to us. As with almost all questions on SO if you show us some code you will get more help – RiggsFolly Aug 31 '18 at 07:52

1 Answers1

1

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.

You can add the following to your script to temporarily disable 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.

This is harder without more information about the application you are trying to debug. You can start by ensuring your error display is turned on.

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

However, if that doesn't work I would suggest debugging your application with 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).

George
  • 2,860
  • 18
  • 31
  • Thanks, @George, WAMP error reporting is set to log all errors by default and as I wrote in the question, Xdebug is installed and was running. It didn't produce any output and/or logged events. As for disabling OPcache temporarily, I know how to do that, but that actually requires me to go through all the extensions to figure out which one fails, including OPcache, which is what I want to avoid. I want OPcache to report when, where and why it fails when it does.. How? – Nikita 웃 Sep 04 '18 at 09:50
  • The last part of my answer points to step debugging which may be your best option in cases like this, allowing for you to interactively walk through the code during runtime. It's definitely worth the time and effort it requires to set up. – George Sep 04 '18 at 12:44