Message - bad access


#1

I have a problem with my Plugin under Cubase 5.5(with the latest tip),

after i close cubase (and there is at least one instance open of my plugin) -> cubase crashes,
can it be that somehow messages will be deleted even if they are somehow still in the applications message queue?

#0 0x93e12f87 in objc_msgSend #1 0x1dc89930 in ?? #2 0x9a88fdd2 in __CFRunLoopDoObservers #3 0x9a84bced in __CFRunLoopRun #4 0x9a84b3c4 in CFRunLoopRunSpecific #5 0x9a84b1f1 in CFRunLoopRunInMode #6 0x947a3e04 in RunCurrentEventLoopInMode #7 0x947a3af5 in ReceiveNextEventCommon #8 0x947a3a3e in BlockUntilNextEventMatchingListInMode #9 0x9328d595 in _DPSNextEvent #10 0x9328cdd6 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] #11 0x934c65d8 in -[NSApplication _shouldTerminate] #12 0x934c60a5 in -[NSApplication terminate:] #13 0x015e157b in CResampleBase::~CResampleBase #14 0x015e40be in CResampleBase::~CResampleBase #15 0x01360a30 in CResampleBase::~CResampleBase #16 0x015e194e in CResampleBase::~CResampleBase #17 0x934c7356 in -[NSApplication _docController:shouldTerminate:] #18 0x934c6e7c in -[NSDocumentController(NSInternal) _continueTerminationHavingClosedAllDocuments:context:] #19 0x934c6c5a in -[NSDocumentController(NSInternal) _shouldTerminateWithDelegate:shouldTerminateSelector:] #20 0x934c6533 in -[NSApplication _shouldTerminate] #21 0x934c60a5 in -[NSApplication terminate:] #22 0x015e157b in CResampleBase::~CResampleBase #23 0x932cba26 in -[NSApplication sendAction:to:from:] #24 0x015e1671 in CResampleBase::~CResampleBase #25 0x932cb8d9 in -[NSMenuItem _corePerformAction] #26 0x932cb5ca in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] #27 0x932cb4b6 in -[NSMenu performActionForItemAtIndex:] #28 0x932cb469 in -[NSMenu _internalPerformActionForItemAtIndex:] #29 0x932cb3cf in -[NSMenuItem _internalPerformActionThroughMenuIfPossible] #30 0x932cb313 in -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] #31 0x932bfa55 in NSSLMMenuEventHandler #32 0x94776c2f in DispatchEventToHandlers #33 0x94775ef6 in SendEventToEventTargetInternal #34 0x947987f3 in SendEventToEventTarget #35 0x947c4e87 in SendHICommandEvent #36 0x947e9b90 in SendMenuCommandWithContextAndModifiers #37 0x947e9b47 in SendMenuItemSelectedEvent #38 0x947e9a5d in FinishMenuSelection #39 0x947b9160 in MenuSelectCore #40 0x947b88bb in _HandleMenuSelection2 #41 0x947b86d9 in _HandleMenuSelection #42 0x932b8f96 in _NSHandleCarbonMenuEvent #43 0x9328db46 in _DPSNextEvent #44 0x9328cdd6 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] #45 0x9324f1f3 in -[NSApplication run] #46 0x015e3f50 in CResampleBase::~CResampleBase #47 0x01360b19 in CResampleBase::~CResampleBase #48 0x013121a0 in CResampleBase::~CResampleBase


#2

i think the problem happens always when the VSTPlugin will be deleted while the GUI is open, is there anyway to debug (show,dispatch) the pending messages…


#3

The problem may be that the host has unloaded your plugin from memory before all of its messages have been delivered, so that when it tries to deliver it, the object no longer exists. Ideally, hosts would wait a couple of seconds after closing a plugin before they unload its DLL, but they don’t do that.

Not sure what to suggest - there are places in the code where I’ve tried to briefly spin the message loop to allow these things to get cleared out before quitting, but that’s the best I could do. If you can find a better way to inspect and clean up the message queue, let me know!


#4

thanks, i reduced (not finally remove) the issue, i had a ThreadWithProgressWindow associated with a Component, which is always holding a references to a window even when its not used and not visible.

But i still get the error from time to time. Is it possible to check, when the last plugin is closed, and Cubase calls the dispatcher with editor Close Opcode, inside the dispatcher (because it is the message-thread) to proceed all messages in the message loop, and avoid new message postings (sorry my knowledge about the whole os message-system is rudimentary)


#5

mmh i have ongoing issues with similar crashes, does anybody has the same problems too?


#6

Maybe you can move (if possible) some of the relevant code to the editor - that way you’ll have a better chance that there will be enough time for the shutdown process.