Why Do I Get Stack Overflow When I Have A Condition That Is Guaranteed to Solve Itself?
I am trying to build a midi note range limiter, but get a senseless stack overflow message. Here is what my patcher logic looks like:
----------begin_max5_patcher---------- 542.3oc0W9saaBCEF+Z3ovx2NVD1FHlocydNlpl3OdstBriBNZYqpu6Ce.ZI UQESCgndCV19X6uyOr+L7juGNWeTzfQeC8Sjm2S9ddPS1F75q6gqyNVTk0.g gUGpyE6wAcc8asxnxpEPW+XuLqZnm13zGLUBCLLZeq6xLEOHU2+q8hBS2xxo waBCPjsg1hX3IguIDcW+X5lFye2I5F.VpL3.DNOScO9knjkfFz4O9URX3X80 H+GLRhcpeQbR0f1H11d1229H3lQgs.EhBWLJjx+zAgT5RCAd5UGBh+ztPCqh QbDxErbtXgLIVXL.HL5lXWvxY2SLqCFzkCGeAQnKHQ5OsvRhuXhPtQDQdEvw BrAgdivQinBQPgyEJrIgBsyFIJYZyDvEI30xySH101QoPWWKr9ZuAQ4ZiQWi TZiXnuJoRTnOnLiMVckcguC6R67dS5X2V.joiX2XfD846x19zK04sFSdYa7M 5dluu71HTxk6pl7QsQfYC1W+luJEzqs8SYTi9v9hA4LXnidUxkhFiTkYjZ03 fRNInGjkkB03yD0xxc51rqWDbdjEFr1hVxvSH.fNoFExtgHgZn6N66YWyD3y XmNUrAQlQpv5RktWxoQbHUr0VG4RuD4xSWL4Z8wGIj2AtyYexH80B2QZeITq SrcFpccdgmrphxsi+70USwtxIx5oIpKZhrtbJwEMwVWM4xdb6eY9g0Takm8+ O3Df7+K -----------end_max5_patcher-----------
now, if you remove the patchcord running from the [+12] object back to the [ < ] object, it runs fine. See, eventually the patch will solve itself, because if you add 12 enough times, you’ll eventually get a value higher than what’s given as the bottom note value. Why then will Max not allow this?
There’s no way for a patch to "know"
that it will solve itself.
Perhaps another look at the paragraph
"The Trouble With Loops" in Max Tutorial
5 might help to refresh your memory as to
why loops are bad things.
You might also benefit from the split object.
Note that Max has a finite amount of memory to work with.
If your patch has a feedback loop, Max (or any program) has basically two options: (1) interrupt processing before the stack overwrites some other area of memory or (2) crash.
By and large, the former of the two options is considered preferable.
There are a zillion other ways to implement what you’re trying to do without eating up ridiculous amounts of memory.