# Probable bug in AudioProcessor/AudioProcessorParameter

**URL:** <https://forum.juce.com/t/probable-bug-in-audioprocessor-audioprocessorparameter/15989>\
**Category:** Audio Plugins\
**Created:** [November 18, 2015, 7:56am UTC](https://forum.juce.com/t/probable-bug-in-audioprocessor-audioprocessorparameter/15989 "2015-11-18T07:56:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raph11](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@raph11](https://forum.juce.com/u/raph11)\
**Post date:** [November 18, 2015, 7:56am UTC](https://forum.juce.com/t/probable-bug-in-audioprocessor-audioprocessorparameter/15989/1 "2015-11-18T07:56:14Z")

</div>

I tried to implement parameters myself in AudioProcessor and crashed a couple of hosts. The bug involves overriding AudioProcessor::getNumParameters() but not getParameterText(), and implementing parameter change gestures in the GUI.

&nbsp;

from the JUCE source I found on github a week ago:

const String AudioProcessor::getParameterText (int index)  
{  
&nbsp;&nbsp;&nbsp; return getParameterText (index, 1024);  
}

String AudioProcessor::getParameterText (int index, int maximumStringLength)  
{  
&nbsp;&nbsp;&nbsp; if (AudioProcessorParameter\* p = managedParameters[index])  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return p-\>getText (p-\>getValue(), maximumStringLength);

&nbsp;&nbsp;&nbsp; return getParameterText (index).substring (0, maximumStringLength);  
}

&nbsp;

The two functions call each other recursively, resulting in a stack blow and a crash. Depending on the host, the crash might not even happen in the plugin's call stack either (FL studio crashed in FLEngine.dll at an unknown location, VSTScanner showed the correct location).

In other news, I found an efficient way to crash the VST host with cryptic error messages, just blow the stack.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 24, 2015, 12:47pm UTC](https://forum.juce.com/t/probable-bug-in-audioprocessor-audioprocessorparameter/15989/2 "2015-11-24T12:47:41Z")

</div>

The thing is that if you're not using the new parameter classes, then you MUST implement at least one of those methods.

They used to be pure-virtual, so it'd have forced you to implement it safely, but I changed that because we no longer want anyone to use them, and I added some default implementations. I guess I can find a way to add an assertion to catch the recursion&nbsp;and make it clear what's wrong, but it's your implementation which needs to change to make it work.

---

<div class="post-metadata">

**Author:** ![raph11](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@raph11](https://forum.juce.com/u/raph11)\
**Post date:** [November 24, 2015, 8:11pm UTC](https://forum.juce.com/t/probable-bug-in-audioprocessor-audioprocessorparameter/15989/3 "2015-11-24T20:11:33Z")

</div>

Thanks for the heads up, that's what I ended up doing. The so called bug is only bad because the crash is very randomly located. That's not on Juce, but I didn't expect a blown stack to crash the host at a random place. I'm also surprised the recursive call stack increment is not optimized out with tail recursion, which would result in a hanging thread.

I almost wrote another bug report (create file in Introjucer in random directory, move them in Visual Studio, move them in Introjucer, delete them in Visual Studio but not Introjucer, move another copy to the correct project directory with command line, Introjucer hangs), but since it involves massive noobage it will probably not be worth your time.

Thanks for Juce, it's real cool.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 24, 2015, 10:27pm UTC](https://forum.juce.com/t/probable-bug-in-audioprocessor-audioprocessorparameter/15989/4 "2015-11-24T22:27:56Z")

</div>

Thanks.&nbsp;I did add&nbsp;an assertion now, so hopefully anyone else who hits this will find it easier to see what's going on.
