# Function Call Tree Too Deep!



## Darius (Mar 29, 2017)

Anyone seen this error before? Know how to fix it?

Seems pretty self-explanatory, however, I can't seem to fix it by calling fewer functions...

Only seem to be getting the error after extensive note bashing, where it pops up often on note/release until the instrument is reset. Leads me to believe there are some functions hanging around doing nothin' for nobody - but I've checked my wait/while clauses and exited functions that have been made redundant, but with no luck.

Any pro tips for bug squishing this? I've reduced it down to a dozen functions/callbacks, but I haven't even made half the program and the UI yet!


----------



## EvilDragon (Mar 29, 2017)

If a function calls another function that calls another function that calls yet another function you might get this warning... Also the function call stack has finite size, so if there are lots of functions called in quick succession, you get an overflow and this error.

Kinda hard to troubleshoot it without any code shown, though.


----------



## kmlandre (Mar 29, 2017)

<NERD_WARNING>
Recurses! Foiled Again!
</NERD_WARNING>


----------



## EvilDragon (Mar 29, 2017)

Funny 

However recursions aren't possible with KSP. But good one


----------



## kmlandre (Mar 29, 2017)

Oh I know, but one is rarely presented with such a golden opportunity. 

I say "damn the details and full speed ahead!!!"


----------



## Darius (Mar 29, 2017)

After some further testing, seems like this is related to the rate of incoming notes. Most likely something to do with this:


EvilDragon said:


> the function call stack has finite size


I made a note generator to test, and found that a note period of 20ms got the error up in ~650 notes (1300 note on/off messages ~13 seconds). Larger periods saw a larger increase in number of note messages it could take, up to 100ms period which is... well... still working after 10 minutes (6000 notes).

Bad news is, once you break it, it's broke - unless anyone knows a fix in code.

Lessons learned: take it for granted VI users will not be using their forehead to play.


----------

