Page MenuHomePhabricator

xdebug and Phabricator dont play nice together
Closed, ResolvedPublic

Description

Using a minimal setup on OSX Mavericks using shipped apache2 and built-from-git xdebug, ie without any xdebug config i ran into a similar issue which seems to have been adressed in D2414.

My problem is that xdebug.max_nesting_level is unset by default (as in 0), which leads to the following:

$ arc unit
PHP Fatal error:  Maximum function nesting level of '0' reached, aborting! in /Users/ml/dev/arcanist/libphutil/scripts/__init_script__.php on line 48
PHP Stack trace:
PHP   1. {main}() /Users/ml/dev/arcanist/arcanist/scripts/arcanist.php:0
PHP   2. require_once() /Users/ml/dev/arcanist/arcanist/scripts/arcanist.php:6
PHP   3. include_once() /Users/ml/dev/arcanist/arcanist/scripts/__init_script__.php:46
PHP   4. __phutil_init_script__() /Users/ml/dev/arcanist/libphutil/scripts/__init_script__.php:91

After the below "fix", the exception goes away:

$ git diff
diff --git a/scripts/__init_script__.php b/scripts/__init_script__.php
index 4270e53..38e869b 100644
--- a/scripts/__init_script__.php
+++ b/scripts/__init_script__.php
@@ -37,7 +37,7 @@ function __phutil_init_script__() {
     // includes (and in other cases, like recursive filesystem operations
     // applied to 100+ levels of directory nesting). Stop it from triggering:
     // we explicitly limit recursive algorithms which should be limited.
-    'xdebug.max_nesting_level'    => null,
+    'xdebug.max_nesting_level'    => 100,

     // Don't limit memory, doing so just generally just prevents us from
     // processing large inputs without many tangible benefits.

However I dont think this is a proper solution, for example T1151 hits the 100 nesting level limit.

Event Timeline

martin.lindhe raised the priority of this task from to Needs Triage.
martin.lindhe updated the task description. (Show Details)
martin.lindhe added a project: libphutil.
martin.lindhe added a subscriber: martin.lindhe.

I think xdebug may have changed its behavior, since I definitely ran with it for a while locally and hopefully wasn't making things up in D2414. We can change this to a very large number instead (e.g., PHP_INT_MAX).

Specifically, does this fix things?

-    'xdebug.max_nesting_level'    => null,
+    'xdebug.max_nesting_level'    => PHP_INT_MAX,

We sometimes exceed 100 levels of function calls during normal operation, but never expect to exceed 4 billion levels.

Well, using PHP_INT_MAX works fine for my use case!

I think it is a clever fix, but never followed the reasoning about the changes the first time around.

XDebug made a change which altered its interpretation of 0 in Feb, 2014:

https://github.com/xdebug/xdebug/commit/11740de6292497b2aed3ae186cadea9493ff0fb5

Prior to that change, 0 meant "disable the check". Now, 0 means "literal limit of 0".

I'll send out a review for the PHP_INT_MAX change.

epriestley triaged this task as Normal priority.

This should be fixed in HEAD. Thanks for the report, and let us know if you run into anything else.