Cubase 7 - JuceDemoPlugin crashing on application close

I frequently get crashes when closing a session in Cubase 7.0.1 when my plug-in’s editor is visible. Crashes are almost repeatable every time if I click on the plug-in GUI and get Cubase drawing stuff in the background. I can repeat the crash with the demo plug-in by clicking inside the GUI and simultaneously quitting the application.

Below is the only interesting part of the crash log. Lines 4 and 16 show as ?? in the debugger i.e. bad memory access.

Cubase 6.5.4 does not have this problem, so I guess the ball is really in Steinberg’s court. Just thought I’d give you all the heads up!

[list]Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 com.steinberg.cubase 0x016ede8d CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 1810717
1 com.steinberg.cubase 0x01923d70 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 4128768
2 com.steinberg.cubase 0x017691a5 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 2315317
3 com.steinberg.cubase 0x015e7ea1 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 737585
4 com.steinberg.cubase 0x00f82913 0x1000 + 16259347
5 com.steinberg.cubase 0x01923d70 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 4128768
6 com.steinberg.cubase 0x01766f2e CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 2306494
7 com.steinberg.cubase 0x016e45d3 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 1771619
8 com.steinberg.cubase 0x01923d70 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 4128768
9 com.steinberg.cubase 0x01636c3b CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 1060555
10 com.steinberg.cubase 0x01636a63 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 1060083
11 com.steinberg.cubase 0x01923d70 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 4128768
12 com.steinberg.cubase 0x016272d2 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 996706
13 com.steinberg.cubase 0x01627213 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 996515
14 com.steinberg.cubase 0x015e084e CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 707294
15 com.steinberg.cubase 0x015e067e CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 706830
16 com.steinberg.cubase 0x00e7c7b9 0x1000 + 15185849
17 com.steinberg.cubase 0x01923d70 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 4128768
18 com.steinberg.cubase 0x018615a7 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 3332151
19 com.steinberg.cubase 0x018615e4 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 3332212
20 com.steinberg.cubase 0x016276c8 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 997720
21 com.steinberg.cubase 0x01864283 CSOLOISTExtendedAnalysis::~CSOLOISTExtendedAnalysis() + 3343635
22 com.apple.AppKit 0x9218f356 -[NSApplication _docController:shouldTerminate:] + 84
23 com.apple.AppKit 0x9218ee7c -[NSDocumentController(NSInternal) _continueTerminationHavingClosedAllDocuments:context:] + 160
24 com.apple.AppKit 0x9218ec5a -[NSDocumentController(NSInternal) _shouldTerminateWithDelegate:shouldTerminateSelector:] + 1376
25 com.apple.AppKit 0x9218e533 -[NSApplication _shouldTerminate] + 373
26 com.apple.AppKit 0x9218e0a5 -[NSApplication terminate:] + 519
27 com.steinberg.cubase 0x01286a57 0x1000 + 19421783[/list]

Erm, no… Since the crash is clearly in your destructor (assuming “CSoloist” is your plugin, right?), then I’d say the ball is in your court.

I wish it was! I can confirm that both the editor and processor destructors are called in the correct order before the application quits. This bug is completely reproducible with a clean Introjucer-built JuceDemoPlugin.

The destructor in the crash log is somewhere deep in Cubase land… if you google CSOLOISTExtendedAnalysis you will get several search results relating to Cubase crashes from different vendors.

Looks like OS level messages are being sent to an already deleted instance, or something along those lines.

Ah, I see. Well yep, sounds like Steinberg’s problem then!

Okey. I have similar problem to one described above. The same problems were discussed here:

http://www.juce.com/forum/topic/cubase-freeze-mountain-lion

http://www.juce.com/forum/topic/cubase-mac-crashes-when-closing-more-guis-fast

And I don't think that it's Steinbergs problem, because other vst plugins are destroyed correctly, but not those written in JUCE. The problem occurs in Wavelab too.

I found out, that the bug is related to focus.  I can load plugins and than unload my inserts without any problems. But always last instance of plugin can't be destroyed if I click anywhere inside of plugin window (tested on 32 Cubase 7 MAC) or moving some sliders. 

There's an easy way to make a test. Load JuceDemoPlugin into insert. Than without clicking inside of it - try to unload. Everything works fine.
 

We can repeat action, but before unloading insert - just click anywhere inside of plugin - boom.... Cubase is goin' mad.

We can repeat action another time, but after moving sliders we have to click on main cubase window - so the plugin loses focus. Everything works fine.

 

I found out, that when I set JucePlugin_EditorRequiresKeyboardFocus to 0,  the problem seems to be solved... But of course TextEditors doesn't work properly.


I think we have to loose focus in Editors destructor, but I don't know how to do it... setWantsKeyboardsFocus(false) doesn't work.

 

Any ideas??

Hmm. Very hard to know what cubase could be doing differently just because of the keyboard focus.

All I can think of to try as an experiment would be to try removing the event loop at line 205 of juce_VST_Wrapper.mm, since that's most often the cause of crashes when closing down.. (I don't have cubase 7 installed myself to try this at the moment)

I removed 
 

        for (int i = 20; --i >= 0;)

            MessageManager::getInstance()->runDispatchLoopUntil (1);

 



from code, but it didn't help. 
I tried many things like:



 

    [hostWindow miniaturize:nil];

    [pluginWindow miniaturize:nil];

    

    [pluginView unlockFocus];

    [pluginView setHidden:true];

    

    [hostWindow orderOut:nil];

    [pluginWindow orderOut:nil];

    

Nothing helped.... Is there is any possibility to loose keyboard focus??

How about calling [pluginWindow resignKeyWindow] and [hostWindow resignKeyWindow] before releasing them? 

No it doesn't work.

I have the same problem, but i have also no cubase to test it here. Can I help on any way?

I'm having a similar issue as well on Mac OS X 10.9 and Cubase 7.5.10. Except that removing the plugin will also crash Cubase. This has me really stumped.

Ok, I have installed 7 elements trail and can test it here for 30 days too :-)

Here cubase only crash's if the plugin-UI still is open on cubase exit. If the plugin-UI hidden/closed, Cubase does not crash. Can anybody confirm this?
I have tried a lot of configs, deployment targets and so on - no chance.

Here my complete crash log: 


Process:         Cubase LE AI Elements 7 [2748]
Path:            /Applications/Cubase LE AI Elements 7.app/Contents/MacOS/Cubase LE AI Elements 7
Identifier:      com.steinberg.cubase.soft
Version:         7.0.6.2231 (7.0.6.2231)
Code Type:       X86 (Native)
Parent Process:  launchd [136]
User ID:         501
Date/Time:       2014-02-09 11:13:32.691 +0100
OS Version:      Mac OS X 10.8.5 (12F45)
Report Version:  10
Interval Since Last Report:          95991 sec
Crashes Since Last Report:           30
Per-App Interval Since Last Report:  753 sec
Per-App Crashes Since Last Report:   14
Anonymous UUID:                      5D4B4124-56ED-F357-A251-DCDDA70E1AC9
Crashed Thread:  0  Dispatch queue: com.apple.main-thread
Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000000001d4
VM Regions Near 0x1d4:
--> __PAGEZERO             0000000000000000-0000000000001000 [    4K] ---/--- SM=NUL  /Applications/Cubase LE AI Elements 7.app/Contents/MacOS/Cubase LE AI Elements 7
    __TEXT                 0000000000001000-0000000002ff0000 [ 47.9M] r-x/rwx SM=COW  /Applications/Cubase LE AI Elements 7.app/Contents/MacOS/Cubase LE AI Elements 7
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.steinberg.cubase.soft         0x0118313c 0x1000 + 18358588
1   com.steinberg.cubase.soft         0x011832ad 0x1000 + 18358957
2   com.steinberg.cubase.soft         0x00bbd40e 0x1000 + 12305422
3   com.steinberg.cubase.soft         0x00bc94ba 0x1000 + 12354746
4   com.steinberg.cubase.soft         0x012a5f8b 0x1000 + 19550091
5   com.steinberg.cubase.soft         0x00bc4713 0x1000 + 12334867
6   com.steinberg.cubase.soft         0x00bc2265 0x1000 + 12325477
7   com.steinberg.cubase.soft         0x00bc2043 0x1000 + 12324931
8   com.steinberg.cubase.soft         0x01479870 0x1000 + 21465200
9   com.steinberg.cubase.soft         0x00ad6f34 0x1000 + 11362100
10  com.steinberg.cubase.soft         0x01134ed5 0x1000 + 18038485
11  com.steinberg.cubase.soft         0x00bc04e3 0x1000 + 12317923
12  com.steinberg.cubase.soft         0x01479870 0x1000 + 21465200
13  com.steinberg.cubase.soft         0x012b8b1e 0x1000 + 19626782
14  com.steinberg.cubase.soft         0x01235253 0x1000 + 19087955
15  com.steinberg.cubase.soft         0x01479870 0x1000 + 21465200
16  com.steinberg.cubase.soft         0x01182469 0x1000 + 18355305
17  com.steinberg.cubase.soft         0x01182233 0x1000 + 18354739
18  com.steinberg.cubase.soft         0x01479870 0x1000 + 21465200
19  com.steinberg.cubase.soft         0x01172812 0x1000 + 18290706
20  com.steinberg.cubase.soft         0x01172753 0x1000 + 18290515
21  com.steinberg.cubase.soft         0x0112e875 0x1000 + 18012277
22  com.steinberg.cubase.soft         0x0112e6de 0x1000 + 18011870
23  com.steinberg.cubase.soft         0x00abbe29 0x1000 + 11251241
24  com.steinberg.cubase.soft         0x01479870 0x1000 + 21465200
25  com.steinberg.cubase.soft         0x013b4dc7 0x1000 + 20659655
26  com.steinberg.cubase.soft         0x013b4e04 0x1000 + 20659716
27  com.steinberg.cubase.soft         0x01172c08 0x1000 + 18291720
28  com.steinberg.cubase.soft         0x013b7aa3 0x1000 + 20671139
29  com.apple.AppKit                  0x935f71b0 -[NSApplication _docController:shouldTerminate:] + 83
30  com.apple.AppKit                  0x935f7118 __91-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke_0 + 253
31  com.apple.AppKit                  0x935f6e4b -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 1526
32  com.apple.AppKit                  0x935f6838 -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 266
33  com.apple.AppKit                  0x935f6708 -[NSApplication _shouldTerminate] + 871
34  com.apple.AppKit                  0x935f583c -[NSApplication terminate:] + 1143
35  com.steinberg.cubase.soft         0x00dee4d7 0x1000 + 14603479
36  libobjc.A.dylib                   0x9545e5d3 -[NSObject performSelector:withObject:] + 70
37  com.apple.AppKit                  0x934b8ad2 -[NSApplication sendAction:to:from:] + 436
38  com.steinberg.cubase.soft         0x00def118 0x1000 + 14606616
39  com.apple.AppKit                  0x935f52fc -[NSMenuItem _corePerformAction] + 529
40  com.apple.AppKit                  0x935f4f8b -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 163
41  com.apple.AppKit                  0x935f4614 -[NSMenu _performActionWithHighlightingForItemAtIndex:sendAccessibilityNotification:] + 79
42  com.apple.AppKit                  0x932d502a -[NSMenu performActionForItemAtIndex:] + 65
43  com.apple.AppKit                  0x932d4fdf -[NSMenu _internalPerformActionForItemAtIndex:] + 45
44  com.apple.AppKit                  0x932d4faa -[NSMenuItem _internalPerformActionThroughMenuIfPossible] + 106
45  com.apple.AppKit                  0x932d4e29 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 162
46  com.apple.AppKit                  0x935ed6ee NSSLMMenuEventHandler + 454
47  com.apple.HIToolbox               0x99e049bb _InvokeEventHandlerUPP(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*, long (*)(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*)) + 36
48  com.apple.HIToolbox               0x99c8c394 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1343
49  com.apple.HIToolbox               0x99c8b780 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 430
50  com.apple.HIToolbox               0x99c9f655 SendEventToEventTarget + 88
51  com.apple.HIToolbox               0x99e0486a SendHICommandEvent(unsigned long, HICommand const*, unsigned long, unsigned long, unsigned char, void const*, OpaqueEventTargetRef*, OpaqueEventTargetRef*, OpaqueEventRef**) + 498
52  com.apple.HIToolbox               0x99c7b984 SendMenuCommandWithContextAndModifiers + 70
53  com.apple.HIToolbox               0x99c7b931 SendMenuItemSelectedEvent + 268
54  com.apple.HIToolbox               0x99c7b7b6 FinishMenuSelection(SelectionData*, MenuResult*, MenuResult*) + 134
55  com.apple.HIToolbox               0x99e50e7e MenuSelectCore(MenuData*, Point, double, unsigned long, OpaqueMenuRef**, unsigned short*) + 623
56  com.apple.HIToolbox               0x99c5c132 _HandleMenuSelection2 + 633
57  com.apple.HIToolbox               0x99c5beaf _HandleMenuSelection + 53
58  com.apple.AppKit                  0x934a635a _NSHandleCarbonMenuEvent + 309
59  com.apple.AppKit                  0x933ccfdf _DPSNextEvent + 2425
60  com.apple.AppKit                  0x933cc16c -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 119
61  com.apple.AppKit                  0x933c25cc -[NSApplication run] + 855
62  com.steinberg.cubase.soft         0x013b4ceb 0x1000 + 20659435
63  com.steinberg.cubase.soft         0x013b4d24 0x1000 + 20659492
64  com.steinberg.cubase.soft         0x01172b53 0x1000 + 18291539
65  com.steinberg.cubase.soft         0x0112eb9c 0x1000 + 18013084
66  com.steinberg.cubase.soft         0x00abc626 0x1000 + 11253286
67  com.steinberg.cubase.soft         0x00dee454 0x1000 + 14603348
68  com.steinberg.cubase.soft         0x000029a5 0x1000 + 6565
Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib            0x906969ae kevent + 10
1   libdispatch.dylib                 0x920b2c71 _dispatch_mgr_invoke + 993
2   libdispatch.dylib                 0x920b27a9 _dispatch_mgr_thread + 53
Thread 2:
0   libsystem_kernel.dylib            0x906937ce mach_msg_trap + 10
1   libsystem_kernel.dylib            0x90692cac mach_msg + 68
2   com.apple.audio.midi.CoreMIDI     0x0349a22d XServerMachPort::ReceiveMessage(int&, void*, int&) + 101
3   com.apple.audio.midi.CoreMIDI     0x034b7ae0 MIDIProcess::RunMIDIInThread() + 144
4   com.apple.audio.midi.CoreMIDI     0x034bdc48 MIDIProcess::MIDIInPortThread::Run() + 24
5   com.apple.audio.midi.CoreMIDI     0x0349b805 XThread::RunHelper(void*) + 17
6   com.apple.audio.midi.CoreMIDI     0x0349b2ee CAPThread::Entry(CAPThread*) + 196
7   libsystem_c.dylib                 0x921da5b7 _pthread_start + 344
8   libsystem_c.dylib                 0x921c4dce thread_start + 34
Thread 3:: com.apple.NSURLConnectionLoader
0   libsystem_kernel.dylib            0x906937ce mach_msg_trap + 10
1   libsystem_kernel.dylib            0x90692cac mach_msg + 68
2   com.apple.CoreFoundation          0x98a21f79 __CFRunLoopServiceMachPort + 185
3   com.apple.CoreFoundation          0x98a2795f __CFRunLoopRun + 1247
4   com.apple.CoreFoundation          0x98a2701a CFRunLoopRunSpecific + 378
5   com.apple.CoreFoundation          0x98a26e8b CFRunLoopRunInMode + 123
6   com.apple.Foundation              0x9836c37a +[NSURLConnection(Loader) _resourceLoadLoop:] + 395
7   com.apple.Foundation              0x983d0448 -[NSThread main] + 45
8   com.apple.Foundation              0x983d03cb __NSThread__main__ + 1396
9   libsystem_c.dylib                 0x921da5b7 _pthread_start + 344
10  libsystem_c.dylib                 0x921c4dce thread_start + 34
Thread 4:
0   libsystem_kernel.dylib            0x90695c02 __select_nocancel + 10
1   libsystem_kernel.dylib            0x9069467b select + 92
2   QtCore                            0x1f2f11ac QProcessManager::run() + 250
3   QtCore                            0x1f223feb QThreadPrivate::start(void*) + 381
4   libsystem_c.dylib                 0x921da5b7 _pthread_start + 344
5   libsystem_c.dylib                 0x921c4dce thread_start + 34
Thread 5:: com.apple.CFSocket.private
0   libsystem_kernel.dylib            0x90695be6 __select + 10
1   com.apple.CoreFoundation          0x98a6b650 __CFSocketManager + 1632
2   libsystem_c.dylib                 0x921da5b7 _pthread_start + 344
3   libsystem_c.dylib                 0x921c4dce thread_start + 34
Thread 6:: JavaScriptCore::BlockFree
0   libsystem_kernel.dylib            0x906958e2 __psynch_cvwait + 10
1   libsystem_c.dylib                 0x921df280 _pthread_cond_wait + 833
2   libsystem_c.dylib                 0x922650d4 pthread_cond_timedwait$UNIX2003 + 70
3   com.apple.JavaScriptCore          0x992584b8 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 120
4   com.apple.JavaScriptCore          0x9946ff63 JSC::BlockAllocator::blockFreeingThreadMain() + 115
5   com.apple.JavaScriptCore          0x9925643c WTF::threadEntryPoint(void*) + 76
6   com.apple.JavaScriptCore          0x994858a0 WTF::wtfThreadEntryPoint(void*) + 16
7   libsystem_c.dylib                 0x921da5b7 _pthread_start + 344
8   libsystem_c.dylib                 0x921c4dce thread_start + 34
Thread 7:: JavaScriptCore::Marking
0   libsystem_kernel.dylib            0x906958e2 __psynch_cvwait + 10
1   libsystem_c.dylib                 0x921df280 _pthread_cond_wait + 833
2   libsystem_c.dylib                 0x92265089 pthread_cond_wait$UNIX2003 + 71
3   com.apple.JavaScriptCore          0x993daaa6 JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode) + 198
4   com.apple.JavaScriptCore          0x993da99e JSC::MarkStackThreadSharedData::markingThreadMain() + 238
5   com.apple.JavaScriptCore          0x9925643c WTF::threadEntryPoint(void*) + 76
6   com.apple.JavaScriptCore          0x994858a0 WTF::wtfThreadEntryPoint(void*) + 16
7   libsystem_c.dylib                 0x921da5b7 _pthread_start + 344
8   libsystem_c.dylib                 0x921c4dce thread_start + 34
Thread 8:: JavaScriptCore::Marking
0   libsystem_kernel.dylib            0x906958e2 __psynch_cvwait + 10
1   libsystem_c.dylib                 0x921df280 _pthread_cond_wait + 833
2   libsystem_c.dylib                 0x92265089 pthread_cond_wait$UNIX2003 + 71
3   com.apple.JavaScriptCore          0x993daaa6 JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode) + 198
4   com.apple.JavaScriptCore          0x993da99e JSC::MarkStackThreadSharedData::markingThreadMain() + 238
5   com.apple.JavaScriptCore          0x9925643c WTF::threadEntryPoint(void*) + 76
6   com.apple.JavaScriptCore          0x994858a0 WTF::wtfThreadEntryPoint(void*) + 16
7   libsystem_c.dylib                 0x921da5b7 _pthread_start + 344
8   libsystem_c.dylib                 0x921c4dce thread_start + 34
Thread 9:: JavaScriptCore::Marking
0   libsystem_kernel.dylib            0x906958e2 __psynch_cvwait + 10
1   libsystem_c.dylib                 0x921df280 _pthread_cond_wait + 833
2   libsystem_c.dylib                 0x92265089 pthread_cond_wait$UNIX2003 + 71
3   com.apple.JavaScriptCore          0x993daaa6 JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode) + 198
4   com.apple.JavaScriptCore          0x993da99e JSC::MarkStackThreadSharedData::markingThreadMain() + 238
5   com.apple.JavaScriptCore          0x9925643c WTF::threadEntryPoint(void*) + 76
6   com.apple.JavaScriptCore          0x994858a0 WTF::wtfThreadEntryPoint(void*) + 16
7   libsystem_c.dylib                 0x921da5b7 _pthread_start + 344
8   libsystem_c.dylib                 0x921c4dce thread_start + 34
Thread 10:
0   libsystem_kernel.dylib            0x906960ee __workq_kernreturn + 10
1   libsystem_c.dylib                 0x921dd0ac _pthread_workq_return + 45
2   libsystem_c.dylib                 0x921dce79 _pthread_wqthread + 448
3   libsystem_c.dylib                 0x921c4daa start_wqthread + 30
Thread 11:
0   libsystem_kernel.dylib            0x906960ee __workq_kernreturn + 10
1   libsystem_c.dylib                 0x921dd0ac _pthread_workq_return + 45
2   libsystem_c.dylib                 0x921dce79 _pthread_wqthread + 448
3   libsystem_c.dylib                 0x921c4daa start_wqthread + 30
Thread 12:
0   libsystem_kernel.dylib            0x906960ee __workq_kernreturn + 10
1   libsystem_c.dylib                 0x921dd0ac _pthread_workq_return + 45
2   libsystem_c.dylib                 0x921dce79 _pthread_wqthread + 448
3   libsystem_c.dylib                 0x921c4daa start_wqthread + 30
Thread 13:: MB Cleanup
0   libsystem_kernel.dylib            0x906958e2 __psynch_cvwait + 10
1   libsystem_c.dylib                 0x921df280 _pthread_cond_wait + 833
2   libsystem_c.dylib                 0x92265089 pthread_cond_wait$UNIX2003 + 71
3   com.steinberg.cubase.soft         0x01488acc 0x1000 + 21527244
4   com.steinberg.cubase.soft         0x010a5298 0x1000 + 17449624
5   com.steinberg.cubase.soft         0x014880a4 0x1000 + 21524644
6   libsystem_c.dylib                 0x921de074 _pthread_body + 72
Thread 14:: CVDisplayLink
0   libsystem_kernel.dylib            0x906958e2 __psynch_cvwait + 10
1   libsystem_c.dylib                 0x921df280 _pthread_cond_wait + 833
2   libsystem_c.dylib                 0x92265089 pthread_cond_wait$UNIX2003 + 71
3   com.apple.CoreVideo               0x94cbc15a CVDisplayLink::runIOThread() + 912
4   com.apple.CoreVideo               0x94cbbdb2 startIOThread(void*) + 160
5   libsystem_c.dylib                 0x921da5b7 _pthread_start + 344
6   libsystem_c.dylib                 0x921c4dce thread_start + 34
Thread 15:
0   libsystem_kernel.dylib            0x906960ee __workq_kernreturn + 10
1   libsystem_c.dylib                 0x921dd0ac _pthread_workq_return + 45
2   libsystem_c.dylib                 0x921dce79 _pthread_wqthread + 448
3   libsystem_c.dylib                 0x921c4daa start_wqthread + 30
Thread 0 crashed with X86 Thread State (32-bit):
  eax: 0x00000000  ebx: 0x2bb94548  ecx: 0x00000201  edx: 0x00000201
  edi: 0x2bb94420  esi: 0x2bb94548  ebp: 0xbfffde48  esp: 0xbfffde30
   ss: 0x00000023  efl: 0x00010286  eip: 0x0118313c   cs: 0x0000001b
   ds: 0x00000023   es: 0x00000023   fs: 0x00000000   gs: 0x0000000f
  cr2: 0x000001d4
Logical CPU: 2

Crazy. If i have 1+n plugins loaded and only one UI is hidden, then cubase also not crash on exit.

I have exactly the same problem right now, Cubase 7 Elements crashes all my JUCE plug-ins when I'm trying to quit a session with the GUI still displayed. I am with Mac OS 10.9.

Same here; every time you close Cubase 32-bit with a JUCE VST plug-in's UI open, it crashes.
 

I've been speaking to one of Cubase's developers, who says:

To pin a Cocoa window to a Carbon window needs to be done correctly and it looks like JUCE doesn't do this correctly.
What I see here is that JUCE is incrementing the reference counter at some point and it never decrements it. That's why Cubase crashes, because the window is destroyed too late when quitting Cubase. 

Note that there was another crash in previous versions of Cubase 7, affecting both JUCE and certain non-JUCE plug-ins, caused by Cubases's premature unloading of the plug-in bundle. That bug is now fixed in Cubase 7.5, and, despite the similar symptoms, unrelated to this one.

There was a ref-counting error which I fixed a couple of weeks ago?

Superb; I'll give this a test, and report back.

 

EDIT: JuceDemoPlugin seems to be working fine now in Cubase 7. Now I just need to work out why my plug-ins are still crashing!

This problem seems to have been fixed in the 32bit VST version, but still occurs in the 64bit version.

 

On OSX 10.9 with Cubase 7.5 and JUCE 3.2.0:

Add juceDemoPlugin to an empty project, click the GUI to give it focus, then quit Cubase (leaving the GUI open), it'll crash.

 

Any chance this'll be fixed too?

On 64-bit it doesn't use Carbon, so the stuff discussed on this thread won't apply.

Most likely you're talking about the old problem of some hosts not allowing time for the message thread to run after deleting an NSWindow, which causes a crash after the plugin has been unloaded from memory. As discussed many times on the forum, we can't do much about this from the plugin side of things.