Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function call depth is higher than 'maxfuncdepth' #125

Open
ahartz1 opened this issue Jun 17, 2020 · 8 comments
Open

Function call depth is higher than 'maxfuncdepth' #125

ahartz1 opened this issue Jun 17, 2020 · 8 comments

Comments

@ahartz1
Copy link

ahartz1 commented Jun 17, 2020

I'm getting this error when attempting to trigger completions on objects:

Error detected while processing function phpcomplete#CompletePHP[97]..phpcomplete#GetClassContents[1]..phpcomplete#GetCachedClassContents[36]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomp
lete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassConte
ntsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152].
.phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetCl
assContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructu
re[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomple
te#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContent
sStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..p
hpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClas
sContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure
[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete
#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsS
tructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..php
complete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassC
ontentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[1
52]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#G
etClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStr
ucture[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpcomplete#GetClassContentsStructure[152]..phpco
mplete#GetClassContentsStructure[142]..phpcomplete#GetClassLocation[14]..phpcomplete#GetCurrentNameSpace:
line  146:
E132: Function call depth is higher than 'maxfuncdepth'

Version of phpcomplete: ff5b5ef

My Vim build info:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun 10 2020 16:42:10)
macOS version
Included patches: 1-950
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +cindent           +cursorshape       +file_in_path      +job               +menu              +mouse_urxvt       +popupwin          +signs             -tcl               +vartabs           -X11
+arabic            -clientserver      +dialog_con        +find_in_path      +jumplist          +mksession         +mouse_xterm       +postscript        +smartindent       +termguicolors     +vertsplit         -xfontset
+autocmd           +clipboard         +diff              +float             +keymap            +modify_fname      +multi_byte        +printer           -sound             +terminal          +virtualedit       -xim
+autochdir         +cmdline_compl     +digraphs          +folding           +lambda            +mouse             +multi_lang        +profile           +spell             +terminfo          +visual            -xpm
-autoservername    +cmdline_hist      -dnd               -footer            +langmap           -mouseshape        -mzscheme          -python            +startuptime       +termresponse      +visualextra       -xsmp
-balloon_eval      +cmdline_info      -ebcdic            +fork()            +libcall           +mouse_dec         +netbeans_intg     +python3           +statusline        +textobjects       +viminfo           -xterm_clipboard
+balloon_eval_term +comments          +emacs_tags        +gettext           +linebreak         -mouse_gpm         +num64             +quickfix          -sun_workshop      +textprop          +vreplace          -xterm_save
-browse            +conceal           +eval              -hangul_input      +lispindent        -mouse_jsbterm     +packages          +reltime           +syntax            +timers            +wildignore
++builtin_terms    +cryptv            +ex_extra          +iconv             +listcmds          +mouse_netterm     +path_extra        +rightleft         +tag_binary        +title             +wildmenu
+byte_offset       +cscope            +extra_search      +insert_expand     +localmap          +mouse_sgr         +perl              +ruby              -tag_old_static    -toolbar           +windows
+channel           +cursorbind        -farsi             +ipv6              +lua               -mouse_sysmouse    +persistent_undo   +scrollbind        -tag_any_white     +user_commands     +writebackup
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/[email protected]/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/
local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.15 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.30.3/lib/perl5/5.30.3/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/[email protected]/Framework
s/Python.framework/Versions/3.8/lib/python3.8/config-3.8-darwin -lpython3.8 -framework CoreFoundation  -lruby.2.7

I've rebuilt my tags file several times (I even added the --output-format=e-ctags, which I had not done previously).

I've tried it with let g:phpcomplete_parse_docblock_comments = 0 and let g:phpcomplete_parse_docblock_comments = 1.

I know that the completion has worked for me in the past, so wanted to bring it to your attention.

Thank you for all of your hard work in maintaining this project—I use the jump to definition feature frequently.

If I've left out any relevant details, please let me know.

@complex857
Copy link
Collaborator

Hi, thanks for the report... Do you by any chance have a section of code that causes this we could isolate? Tell me more about the codebase.

From the stacktrace itself, it seems it's trying to get the content of a class you are extending for (building a list of all that it extended, all the traits loaded in to it). It's a recursive process (calls itself until it runs out of parent classes). Sine the last element on the stack-trace is not the same method (so not just blindly stuck inside the recursion), not sure what to make of it.

Either something funky is going on (most likely), or there's some excessively deep class structures 😅

@ahartz1
Copy link
Author

ahartz1 commented Jun 17, 2020

The codebase is a Laravel 5.4 project (on php 5.6... yes, post-EOL is painful) in a private repo.

I thought for some reason that maxfuncdepth was something from phpcomplete.vim, but it is set by Vim itself. I tried increasing it to 250 from the default 100 just to see what would happen and it just sat searching pegged at 100% CPU for over 45 minutes (until I finally put it out of its misery) when attempting to complete from a type-hinted object within one of the classes that I defined.

To push on the possibility that the complexity of my own interdependent packages were the culprit, I switched to a unit test file with a class directly extending Illuminate\Foundation\Testing\TestCase with no outside references in it and got the same maxfuncdepth behavior when I tried completing from $this->assert (and similar non-exiting with increased depth).

I tried switching to a comparatively simple non-Laravel codebase and found that it would come up with search results, but only from things defined within the current file (not from any of the classes being extended).

Could it be that I have something misconfigured? I’m running the latest head of universal-ctags. I’m invoking ctags with this command: ctags -R --fields=+laimS --languages=php --output-format=e-ctags .

Per your comment on issue #112, I checked the output of :function phpcomplete#CompletePHP and confirmed that it was that of phpcomplete.vim and that the plugin was picked up in the output of :scriptnames.

@complex857
Copy link
Collaborator

complex857 commented Jun 18, 2020

Sounds like somewhere where it tries to find a parent class it ends up looping on itself and re-including the same class over and over again.
It's a bit of a stab in the dark since I don't have an environment where I can reproduce the issue, but I've made a change in the branch issue-125 where I've added a basic cycle detection inside GetClassContentsStructure

Could you try switching to this branch and see if it changes anything? I've left in an echom should you trigger a cycle, run the completion on the spot where you got stuck and see :messages command's bottom if you see it saying what class / file it seems to be in the cycle.

@ahartz1
Copy link
Author

ahartz1 commented Jun 18, 2020

Thank you for your work on this. The good news is that it DOES terminate instead of hanging, but it didn't spit out any file names in the messages; it instead just echoed "0" (zero) 20 different times when trying to complete on a class extending the test class.

@ahartz1
Copy link
Author

ahartz1 commented Jun 18, 2020

I found where you left echom files_classes_loaded commented out and uncommented it. From the files in the list, I can see that it mentions all of the files relevant to a $this-> completion, but did not traverse any more deeply into them. Interestingly, despite their presence in the list, the methods/variables/etc. defined in even that limited set of classes were not included in the search results.

@complex857
Copy link
Collaborator

Ah, I've made a mistake there (string concat is . not + in vimscript) I've pushed a new commit.
Does it still give some result for the completion? I'm pretty sure it's some class-location / identification error being made here (multiple classes with the same name but different namespaces, or such).

My excuse is that I don't have access to my usual machine at hand (damned borders and international lockdowns 😅). I'll try to get some test environment with laravel testing in place.

@ahartz1
Copy link
Author

ahartz1 commented Jun 19, 2020

OK, so with that, I can see that it is the traits that are mentioned in the :messages output. I am getting search results on a completion from $this->, but only from things within the current file.

When attempting to complete from a type-hinted class, I got results, but the results were NOT from the type-hinted class. They were, instead, from the file I was in.

@ahartz1
Copy link
Author

ahartz1 commented Jun 19, 2020

I just noticed some oddities in the search results on the type-hinted class scenario: although it did not return any results from the type-hinted class, it attributed one function from the class I was in to the type-hinted class. Also, only the @property statements in the current class's DocBlock that specify a name-spaced class were included in the results (those of type int, string, array, etc. were not picked up).

A perhaps important note about the above scenario is that it did log a trait (albeit from the current class) as a circular load.

EDIT: I was mistaken about misattribution—I was looking at the return type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants