PluginWindow error when setting AutomatableParameters


I’m making a simple GUI for the built-in Tracktion effects in DAW, I’m building. I’m using the code from PluginWindow.h from the examples and made a class TracktionPluginEditor that simply makes a Slider for each AutomatableParameter.
I set the Slider.onValue lambda like this:

onValueChange = [&] { param.setParameter(this->getValue(), NotificationType::dontSendNotification);

Opening up a plugin window for, say the Tracktion reverb works fine. The parameters show and moving the slider changes the plugin and the sound reacts accordingly. But if I close the plugin window and open up a new one, moving a slider now crashes the program. I get a
JUCE Message Thread (1): EXC_BAD_ACCESS (code=1, address=0x10)
It seems that there’s a bad Listener object being called in the lambda in juce_ValueTree.cpp :

void sendPropertyChangeMessage (const Identifier& property, ValueTree::Listener* listenerToExclude = nullptr)
ValueTree tree (*this);
callListenersForAllParents (listenerToExclude, [&] (Listener& l) {
l.valueTreePropertyChanged (tree, property);

but I can’t figure out why or what the originating object could be. I’ve tried to narrow the suspects down, tracing the calls and it looks like it’s a listener on the Plugin’s listener list.
Each Sliders is registered as a Listener on the AutomatableParameter, but I’m removing it again in the destructor, so I don’t think that’s the issue.

Does anyone have an idea of what might be going wrong?
Any suggestions appreciated!
I’m working on the Master branch btw.

Are you adding a listener somewhere but not removing it?

The easiest way of detecting these kinds of errors is using ASan (Address Sanitiser).

Yes! Found it. PluginWindow added as listener to the plugin’s valuetree, but forgot to remove.
Great tool. I didn’t know that. Thanks!