ComponentPeer::handleKeyUpOrDown() Exception

Windows 10.
Juce Version: 6.0.7

I have no idea what is going on here. Perhaps others have seen this issue?

This exception occurs sporadically:

  • juce_ComponentPeer.cpp
  • ComponentPeer::handleKeyUpOrDown()
  • isKeyDown=true (this is on the key down event)
  • Line: keyWasUsed = keyListeners->getUnchecked(i)->keyStateChanged (isKeyDown, target);

Exception thrown at 0x00007FFEE1FD5B76 (RiverDingo.vst3) in reaper.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF

Seems to be only on the Alt and Shift keys (though I very rarely use and other keys in my plugin).

As usual, this was my fault!

I have a component that was doing this:
(this->getTopLevelComponent()->addKeyListener)(this);

In the destructor I was not doing this:
(this->getTopLevelComponent()->removeKeyListener)(this);