Closing Cubase, breaks, stopping Timer Thread break


#1

Hi together, Hi Jules,

sometimes, not always, when debugging my plugin (in Cubase SX 3) a breakpoint is triggered when Cubase is closing.
It seems to me that a thread tries to kill the Juce-Timer Thread from the GUI which was (maybe?) exited before. (See Debugger Output)
I’m using Juce 1_41.

Breakpoint position:

[code]void Thread::stopThread (const int timeOutMilliseconds)
{
const ScopedLock sl (startStopLock);

if (isThreadRunning())
{
    signalThreadShouldExit();
    notify();

    if (timeOutMilliseconds != 0)
        waitForThreadToExit (timeOutMilliseconds);

    if (isThreadRunning())
    {
        // very bad karma if this point is reached, as
        // there are bound to be locks and events left in
        // silly states when a thread is killed by force..
        jassertfalse 												                    <--------------
        Logger::writeToLog (T("!! killing thread by force !!"));

        juce_killThread (threadHandle_);
        threadHandle_ = 0;
        threadId_ = 0;

        const ScopedLock sl (runningThreadsLock);
        runningThreads.removeValue (this);
    }
}

}
[/code]

Threads

Visual Studio shows only 1 thread

> 3388 _DllMainCRTStartup juce::Thread::stopThread Below Normal 0

Call Stack

>	lib_test_plugin_debug.dll!juce::Thread::stopThread(const int timeOutMilliseconds=16000)  Line 185	C++
 	lib_test_plugin_debug.dll!juce::InternalTimerThread::~InternalTimerThread()  Line 177	C++
 	lib_test_plugin_debug.dll!juce::InternalTimerThread::`scalar deleting destructor'()  + 0x2b bytes	C++
 	lib_test_plugin_debug.dll!juce::DeletedAtShutdown::deleteAll()  Line 79 + 0x34 bytes	C++
 	lib_test_plugin_debug.dll!juce::shutdownJuce_GUI()  Line 344	C++
 	lib_test_plugin_debug.dll!DllMain(HINSTANCE__ * instance=0x0aab0000, unsigned long dwReason=0, void * __formal=0x00000001)  Line 1304	C++
 	lib_test_plugin_debug.dll!__DllMainCRTStartup(void * hDllHandle=0x0aab0000, unsigned long dwReason=0, void * lpreserved=0x00000001)  Line 365 + 0x11 bytes	C
 	lib_test_plugin_debug.dll!_DllMainCRTStartup(void * hDllHandle=0x0aab0000, unsigned long dwReason=0, void * lpreserved=0x00000001)  Line 328 + 0x11 bytes	C
 	ntdll.dll!7c9111a7() 	

Debugger output

...
...
'Cubasesx3.exe': Unloaded 'C:\WINDOWS\system32\cscui.dll'
'Cubasesx3.exe': Unloaded 'C:\WINDOWS\system32\cscdll.dll'
'Cubasesx3.exe': Unloaded 'C:\WINDOWS\system32\msimg32.dll'
'Cubasesx3.exe': Unloaded 'C:\Programme\Steinberg\Cubase SX 3\Components\omffilter.dll'
The thread 'Win32 Thread' (0xdd8) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x5f8) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x960) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x8ec) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x90c) has exited with code 0 (0x0).
The thread 'Juce Timer' (0xf08) has exited with code 0 (0x0).		<-------   Timer exited  
Cubasesx3.exe has triggered a breakpoint          					<-------   Break
** Warning - Forced thread termination **					        <-------   ties to kill Juce-Timer
Detected memory leaks!
Dumping objects ->
c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {2236353} normal block at 0x0EF23BC8, 24 bytes long.
 Data: < '              > D4 27 FA 0A CD CD CD CD CD CD CD CD CD CD CD CD 
Object dump complete.
Detected memory leaks!
Dumping objects ->
c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {2236353} normal block at 0x0EF23BC8, 24 bytes long.
 Data: < '              > D4 27 FA 0A CD CD CD CD CD CD CD CD CD CD CD CD 
Object dump complete.
The thread '_DllMainCRTStartup' (0xd3c) has exited with code 0 (0x0).
The program '[3356] Cubasesx3.exe: Native' has exited with code 0 (0x0).

Some locals

[code]
- [juce::InternalTimerThread] {firstTimer=0x00000000 callbackNeeded=true } juce::InternalTimerThread
- juce::Thread {threadName_={…} threadHandle_=0x00001180 startStopLock={…} …} juce::Thread
+ vfptr 0x0afa1b88 const juce::InternalTimerThread::vftable'{forjuce::Thread’} *
- threadName
{empty={…} text=0x0b150e48 emptyString={…} } const juce::String
+ empty {empty={…} text=0x0aff3e68 emptyString={…} } juce::String
- text 0x0b150e48 {refCount=1 allocatedNumChars=10 text=0x0b150e50 “Juce Timer” }
juce::String::InternalRefCountedStringHolder *
refCount 1 int
allocatedNumChars 10 int
+ text 0x0b150e50 “Juce Timer” wchar_t [1]
+ emptyString {refCount=1073741719 allocatedNumChars=0 text=0x0aff3e70 “” }
juce::String::InternalRefCountedStringHolder
threadHandle
0x00001180 void * volatile
- startStopLock {internal=0x04f15184 "


#2

Strange - looks like your timer thread is getting messed up - it looks like the timer thread exits cleanly but is then killed again somehow… Maybe put a breakpoint in the timer thread constructor/destructor and see what’s going on?


#3

The problem does not always happen, so its difficult to see whats going on with a breakpoint. So i added some logging statements, to the thread and timer Class in this form.

#if JUCE_DEBUG String s("\nThread::waitForThreadToExit"); s+=T(" Name:")+getThreadName(); s+=T(" ID:")+String().toHexString(getThreadId()); DBG(s); #endif

#if JUCE_DEBUG String s("\nTimer destructor start "+String((int64)this)); s+=T(" countdownMs=")+String(countdownMs); s+=T(" isTimerRunning=")+String(isTimerRunning()); s+=T(" next=")+String((int64)next); s+=T(" periodMs=")+String(periodMs); s+=T(" previous=")+String((int64)previous); DBG(s); #endif

I’m not sure if it helps to find the problem.
You see there are some memory-leaks, can this be the problem (maybe from the message-queue)?

I use my own “lookandfeel” but the problem appears without using this lookandfeel too.

[size=150]The output when thread is closing correct, 0xed8 is the timer[/size]




‘Cubasesx3.exe’: Loaded ‘C:\WINDOWS\system32\msvcr71.dll’, No symbols loaded.
‘Cubasesx3.exe’: Loaded ‘C:\WINDOWS\system32\msvcp71.dll’, No symbols loaded.
‘Cubasesx3.exe’: Loaded ‘C:\Programme\Steinberg\Cubase SX 3\Vstplugins\develop\my_lib_test_plugin_debug.dll’, Symbols loaded.
JUCE v1.41

Thread::Thread Name:Juce Timer ID:0
Thread::notify() Name:Juce Timer ID:0

Timer destructor start 83321332 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 83321332 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor start 83324020 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 83324020 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::notify() Name:Juce Timer ID:0

Timer destructor start 315100560 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 315100560 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor start 315099376 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 315099376 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::notify() Name:Juce Timer ID:0

Thread::startThread() Name:Juce Timer ID:0

Thread::startThread(const int priority) Name:Juce Timer ID:0

Thread::wait Name:Juce Timer ID:ed8
Thread::wait Name:Juce Timer ID:ed8

‘Cubasesx3.exe’: Loaded ‘C:\WINDOWS\system32\mscms.dll’, No symbols loaded.
‘Cubasesx3.exe’: Loaded ‘C:\WINDOWS\system32\icm32.dll’, No symbols loaded.

Thread::notify() Name:Juce Timer ID:ed8
Thread::wait Name:Juce Timer ID:ed8
Thread::wait Name:Juce Timer ID:ed8
Thread::wait Name:Juce Timer ID:ed8
Thread::notify() Name:Juce Timer ID:ed8
Thread::wait Name:Juce Timer ID:ed8
Thread::wait Name:Juce Timer ID:ed8
Thread::wait Name:Juce Timer ID:ed8
etc…

Timer destructor start 315078632 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 315078632 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::wait Name:Juce Timer ID:ed8

Timer destructor start 315077768 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0

Timer destructor end 315077768 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::notify() Name:Juce Timer ID:ed8

Thread::wait Name:Juce Timer ID:ed8

Timer destructor start 315115628 countdownMs=2805 isTimerRunning=1 next=0 periodMs=3000 previous=83333140
Timer destructor end 315115628 countdownMs=2805 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::wait Name:Juce Timer ID:ed8
Thread::wait Name:Juce Timer ID:ed8
Thread::wait Name:Juce Timer ID:ed8
etc…

Timer destructor start 83328424 countdownMs=-1 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 83328424 countdownMs=-1 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::wait Name:Juce Timer ID:ed8

Timer destructor start 83333140 countdownMs=999 isTimerRunning=1 next=0 periodMs=999 previous=0
Timer destructor end 83333140 countdownMs=999 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor start 83318588 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 83318588 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::isThreadRunning() Name:Juce Timer ID:ed8
Thread::signalThreadShouldExit() Name:Juce Timer ID:ed8
Thread::notify() Name:Juce Timer ID:ed8
Thread::isThreadRunning() Name:Juce Timer ID:0
Thread::threadEntryPoint Name:Juce Timer ID:0
Thread::waitForThreadToExit Name:Juce Timer ID:0
Thread::isThreadRunning() Name:Juce Timer ID:0
Thread::stopThread Name:Juce Timer ID:0
Thread::isThreadRunning() Name:Juce Timer ID:0
Thread::stopThread Name:Juce Timer ID:0
Thread::~Thread() Name:Juce Timer ID:0

Timer destructor start 83314428 countdownMs=250 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 83314428 countdownMs=250 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::stopAllThreads

Thread::getNumRunningThreads()
Detected memory leaks!
Dumping objects ->
c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {321656} normal block at 0x14FCA8C8, 24 bytes long.
Data: < > FC 96 BA 0C CD CD CD CD CD CD CD CD CD CD CD CD
c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {307229} normal block at 0x12C88648, 24 bytes long.
Data: < > FC 96 BA 0C 00 00 00 00 00 00 00 00 00 00 00 00
c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {89015} normal block at 0x10826D60, 320 bytes long.
Data: < e > 00 01 00 01 01 01 00 01 02 01 00 01 01 65 00 01
c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {89016} normal block at 0x10826F60, 320 bytes long.
Data: < DD > FF BB BB FF FF 44 44 FF 00 00 00 FF 00 00 00 FF
c:\cpp_projects\juce\src\juce_appframework\gui\components\lookandfeel\mylookandfeel.h(194) : {88976} normal block at 0x12C87508, 64 bytes long.
Data: <4l > 34 6C BA 0C C0 BA BA 0C 00 00 00 00 00 00 00 00
Object dump complete.
Detected memory leaks!
Dumping objects ->
c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {321656} normal block at 0x14FCA8C8, 24 bytes long.
Data: < > FC 96 BA 0C CD CD CD CD CD CD CD CD CD CD CD CD
c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {307229} normal block at 0x12C88648, 24 bytes long.
Data: < > FC 96 BA 0C 00 00 00 00 00 00 00 00 00 00 00 00
c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {89015} normal block at 0x10826D60, 320 bytes long.
Data: < e > 00 01 00 01 01 01 00 01 02 01 00 01 01 65 00 01
c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {89016} normal block at 0x10826F60, 320 bytes long.
Data: < DD > FF BB BB FF FF 44 44 FF 00 00 00 FF 00 00 00 FF
c:\cpp_projects\juce\src\juce_appframework\gui\components\lookandfeel\mylookandfeel.h(194) : {88976} normal block at 0x12C87508, 64 bytes long.
Data: <4l > 34 6C BA 0C C0 BA BA 0C 00 00 00 00 00 00 00 00
Object dump complete.
‘Cubasesx3.exe’: Unloaded 'C:\Programme\Steinberg\Cubase SX 3\Vstplugins\develop\my_lib_test_plugin_debug.dll’
The thread ‘Juce Timer’ (0xed8) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xfc8) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x958) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xeb8) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xd4) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xcb8) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xe34) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xaa4) has exited with code 0 (0x0).
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\msvcp71.dll’
‘Cubasesx3.exe’: Unloaded 'C:\WINDOWS\system32\msvcr71.dll’
The thread ‘Win32 Thread’ (0x9bc) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x8f8) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xaf0) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x6e4) has exited with code 1324 (0x52c).
The thread ‘Win32 Thread’ (0xf2c) has exited with code 3366 (0xd26).
The thread ‘Win32 Thread’ (0x9a0) has exited with code 39321 (0x9999).
The thread ‘Win32 Thread’ (0x524) has exited with code 1 (0x1).
The thread ‘Win32 Thread’ (0x168) has exited with code 1 (0x1).
The thread ‘Win32 Thread’ (0xe54) has exited with code 44 (0x2c).
The thread ‘Win32 Thread’ (0xcd0) has exited with code 0 (0x0).
‘Cubasesx3.exe’: Unloaded 'C:\Programme\Steinberg\Cubase SX 3\TimeBandit.dll’
The thread ‘Win32 Thread’ (0xde4) has exited with code 0 (0x0).
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\ReWire.dll’
‘Cubasesx3.exe’: Unloaded ‘C:\Programme\Steinberg\Cubase SX 3\convif.opt’
‘Cubasesx3.exe’: Unloaded ‘C:\Programme\Steinberg\Cubase SX 3\audioprimitives.opt’
‘Cubasesx3.exe’: Unloaded ‘C:\Programme\Steinberg\Cubase SX 3\audiochannel.opt’
‘Cubasesx3.exe’: Unloaded ‘C:\Programme\Steinberg\Cubase SX 3\audiodsp.opt’
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\fireface_asio.dll’
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\cscui.dll’
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\cscdll.dll’
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\msimg32.dll’
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\ksproxy.ax
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\ksuser.dll’
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\devenum.dll’
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\dmsynth.dll’
‘Cubasesx3.exe’: Unloaded ‘C:\WINDOWS\system32\dmusic.dll’
‘Cubasesx3.exe’: Unloaded 'C:\Programme\Steinberg\Cubase SX 3\Components\omffilter.dll’
The thread ‘Win32 Thread’ (0x1f4) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xa50) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xb80) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x80c) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xd00) has exited with code 0 (0x0).
The program ‘[3468] Cubasesx3.exe: Native’ has exited with code 0 (0x0).

[size=150]
The output when it breaks, 0xe1c is the problematic timer[/size]

1000x
Thread::wait Name:Juce Timer ID:e1c
Thread::wait Name:Juce Timer ID:e1c
Thread::wait Name:Juce Timer ID:e1c
Thread::wait Name:Juce Timer ID:e1c
etc…

The thread ‘Win32 Thread’ (0xb8c) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xbcc) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x478) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x4c0) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xe14) has exited with code 0 (0x0).

Thread::wait Name:Juce Timer ID:e1c
The thread ‘Juce Timer’ (0xe1c) has exited with code 0 (0x0).

Timer destructor start 315206436 countdownMs=999 isTimerRunning=1 next=0 periodMs=999 previous=0
Timer destructor end 315206436 countdownMs=999 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor start 82925372 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 82925372 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::isThreadRunning() Name:Juce Timer ID:e1c
Thread::signalThreadShouldExit() Name:Juce Timer ID:e1c
Thread::notify() Name:Juce Timer ID:e1c

1000x
Thread::isThreadRunning() Name:Juce Timer ID:e1c
Thread::isThreadRunning() Name:Juce Timer ID:e1c
Thread::isThreadRunning() Name:Juce Timer ID:e1c
Thread::isThreadRunning() Name:Juce Timer ID:e1c
Thread::isThreadRunning() Name:Juce Timer ID:e1c
Thread::isThreadRunning() Name:Juce Timer ID:e1c
Thread::isThreadRunning() Name:Juce Timer ID:e1c
etc.

Cubasesx3.exe has triggered a breakpoint
** Warning - Forced thread termination **

Thread::stopThread Name:Juce Timer ID:0
Thread::isThreadRunning() Name:Juce Timer ID:0
Thread::stopThread Name:Juce Timer ID:0
Thread::~Thread() Name:Juce Timer ID:0

Timer destructor start 82921212 countdownMs=250 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 82921212 countdownMs=250 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::stopAllThreads

Thread::getNumRunningThreads()
Detected memory leaks!
Dumping objects ->
c:\cpp_projects\juce\src\juce_core\text\juce_string.cpp(108) : {2144441} normal block at 0x15010918, 84 bytes long.
Data: < T h r > 01 00 00 00 24 00 00 00 0A 00 54 00 68 00 72 00 c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {2133745} normal block at 0x108154D0, 24 bytes long. Data: < > FC 96 FB 0A CD CD CD CD CD CD CD CD CD CD CD CD c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {2115503} normal block at 0x15010418, 24 bytes long. Data: < > FC 96 FB 0A 00 00 00 00 00 00 00 00 00 00 00 00 c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {116835} normal block at 0x110027C8, 320 bytes long. Data: < DD > FF BB BB FF FF 44 44 FF 00 00 00 FF 00 00 00 FF c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {116833} normal block at 0x11002AA8, 320 bytes long. Data: < e > 00 01 00 01 01 01 00 01 02 01 00 01 01 65 00 01 c:\cpp_projects\juce\src\juce_appframework\gui\components\lookandfeel\mylookandfeel.h(194) : {116800} normal block at 0x11002748, 64 bytes long. Data: <4l > 34 6C FB 0A C0 BA FB 0A 00 00 00 00 00 00 00 00 Object dump complete. Detected memory leaks! Dumping objects -> c:\cpp_projects\juce\src\juce_core\text\juce_string.cpp(108) : {2144441} normal block at 0x15010918, 84 bytes long. Data: < T h r > 01 00 00 00 24 00 00 00 0A 00 54 00 68 00 72 00
c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {2133745} normal block at 0x108154D0, 24 bytes long.
Data: < > FC 96 FB 0A CD CD CD CD CD CD CD CD CD CD CD CD
c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {2115503} normal block at 0x15010418, 24 bytes long.
Data: < > FC 96 FB 0A 00 00 00 00 00 00 00 00 00 00 00 00
c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {116835} normal block at 0x110027C8, 320 bytes long.
Data: < DD > FF BB BB FF FF 44 44 FF 00 00 00 FF 00 00 00 FF
c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {116833} normal block at 0x11002AA8, 320 bytes long.
Data: < e > 00 01 00 01 01 01 00 01 02 01 00 01 01 65 00 01
c:\cpp_projects\juce\src\juce_appframework\gui\components\lookandfeel\mylookandfeel.h(194) : {116800} normal block at 0x11002748, 64 bytes long.
Data: <4l > 34 6C FB 0A C0 BA FB 0A 00 00 00 00 00 00 00 00
Object dump complete.
The program ‘[760] Cubasesx3.exe: Native’ has exited with code 0 (0x0).


#4

“\juce\src\juce_appframework\gui\components\lookandfeel\mylookandfeel.h”??? WTF? Get your leaks and dodgy hacks tidied up first, then I might look into this! I’ve seen problems before where look and feel objects left lying around can break the shutdown process.


#5

ok, no problem

i compiled the Demo-Plugin from the AudioPlugin-Wrapper, with an original Juce 1_41. I get the same leaks.
2 of them you see in the log, are from juce_UseDebuggingNewOperator:
c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81)
c:\cpp_projects\juce\src\juce_appframework\gui\components\lookandfeel\juce_shinylookandfeel.h(173)

The number of “juce_message.h” memory leaks is various. Between 1-3.

But, and that is the good news, i don’t get the breakpoint issue till yet.
I will investigate.

'Cubasesx3.exe': Loaded 'C:\WINDOWS\system32\msvcr71.dll', No symbols loaded. 'Cubasesx3.exe': Loaded 'C:\WINDOWS\system32\msvcp71.dll', No symbols loaded. 'Cubasesx3.exe': Loaded 'C:\Programme\Steinberg\Cubase SX 3\Vstplugins\develop\juce_vst.dll', Symbols loaded. JUCE v1.41 'Cubasesx3.exe': Loaded 'C:\WINDOWS\system32\mscms.dll', No symbols loaded. 'Cubasesx3.exe': Loaded 'C:\WINDOWS\system32\icm32.dll', No symbols loaded. Detected memory leaks! Dumping objects -> c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {121694} normal block at 0x04F8B0E0, 24 bytes long. Data: <8+ > 38 2B 9F 0C CD CD CD CD CD CD CD CD CD CD CD CD c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {121693} normal block at 0x04F826C8, 24 bytes long. Data: <8+ > 38 2B 9F 0C 00 00 00 00 00 00 00 00 00 00 00 00 c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {269} normal block at 0x04F88638, 320 bytes long. Data: < e > 00 01 00 01 01 01 00 01 02 01 00 01 01 65 00 01 c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {270} normal block at 0x04F88A18, 320 bytes long. Data: < DD > FF BB BB FF FF 44 44 FF 00 00 00 FF 00 00 00 FF c:\cpp_projects\juce\src\juce_appframework\gui\components\lookandfeel\juce_shinylookandfeel.h(173) : {250} normal block at 0x04F885B8, 64 bytes long. Data: < HX > F4 0D 9F 0C 48 58 9F 0C 00 00 00 00 00 00 00 00 Object dump complete. Detected memory leaks! Dumping objects -> c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {121694} normal block at 0x04F8B0E0, 24 bytes long. Data: <8+ > 38 2B 9F 0C CD CD CD CD CD CD CD CD CD CD CD CD c:\cpp_projects\juce\src\juce_appframework\events\juce_message.h(81) : {121693} normal block at 0x04F826C8, 24 bytes long. Data: <8+ > 38 2B 9F 0C 00 00 00 00 00 00 00 00 00 00 00 00 c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {269} normal block at 0x04F88638, 320 bytes long. Data: < e > 00 01 00 01 01 01 00 01 02 01 00 01 01 65 00 01 c:\cpp_projects\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {270} normal block at 0x04F88A18, 320 bytes long. Data: < DD > FF BB BB FF FF 44 44 FF 00 00 00 FF 00 00 00 FF c:\cpp_projects\juce\src\juce_appframework\gui\components\lookandfeel\juce_shinylookandfeel.h(173) : {250} normal block at 0x04F885B8, 64 bytes long. Data: < HX > F4 0D 9F 0C 48 58 9F 0C 00 00 00 00 00 00 00 00 Object dump complete. 'Cubasesx3.exe': Unloaded 'C:\Programme\Steinberg\Cubase SX 3\Vstplugins\develop\juce_vst.dll' The thread 'Juce Timer' (0xb7c) has exited with code 0 (0x0). The thread 'Win32 Thread' (0xae4) has exited with code 0 (0x0).


#6

Oh yes, sorry! Looks like it’s me whose dodgy code was leaking the look and feel! Oops!

Quick fix would be this, in DemoEditorComponent.cpp:

class AutoDeletedLookAndFeel : public ShinyLookAndFeel, public DeletedAtShutdown { public: AutoDeletedLookAndFeel() {} };

and create one of those instead of the default one.

Don’t worry about a couple of leaked messages - that’s unavoidable when sometimes the plugin gets killed while there are some messages still sittin g in the app’s event queue.


#7

bad news:

i get the breakpoint issue, the call-stack is the same like in my first post

> juce_vst.dll!juce::Thread::stopThread(const int timeOutMilliseconds=4000) Line 185 C++ juce_vst.dll!juce::InternalTimerThread::~InternalTimerThread() Line 177 C++ juce_vst.dll!juce::InternalTimerThread::`scalar deleting destructor'() + 0x2b bytes C++ juce_vst.dll!juce::DeletedAtShutdown::deleteAll() Line 79 + 0x34 bytes C++ juce_vst.dll!juce::shutdownJuce_GUI() Line 344 C++ juce_vst.dll!DllMain(HINSTANCE__ * instance=0x0aab0000, unsigned long dwReason=0, void * __formal=0x00000001) Line 1257 C++ juce_vst.dll!__DllMainCRTStartup(void * hDllHandle=0x0aab0000, unsigned long dwReason=0, void * lpreserved=0x00000001) Line 365 + 0x11 bytes C juce_vst.dll!_DllMainCRTStartup(void * hDllHandle=0x0aab0000, unsigned long dwReason=0, void * lpreserved=0x00000001) Line 328 + 0x11 bytes C


#8

sorry, i didn’t read your last post before answering.
Fine, there are only the message-leaks, ok i can live with that, but why gets the timer thread killed?..:?

Do you have any ideas? some kinds of open locked CriticalSections, mmhh…


#9

The only thing I can think of would be if cubase was deleting the plugin during a recursive idle callback - i.e. the plugin is calling cubase’s idle function and in that it’s deleting the plugin. Or if a lock is getting jammed somewhere.

What we need to know is the stack trace when this thread is getting killed. That’d show which other thread is stuck, and why.

I don’t have cubase installed on my machine at the moment, so can’t try it here!


#10

maybe cubase puts all thread ids in an array, and then kills them one by one :shock:


#11

ok, maybe i have something.

when the problem appears, Cubase killed the timer-thread by force, because the timer-thread wasn’t in Thread::wait. So it never had the chance to bring itself to an end.

So what we can do is to tell the timer thread to quit itself, at the beginning when the main-window is closed and wait for it. So it has a little more time to do that.

Good Idea/Bad Idea, or is it nonsense? :?


#12

The timer should get killed cleanly when the DLL is unloaded. I find it hard to believe that cubase would go around killing threads before unloading the DLL…


#13

Sorry i think i was wrong.

The thread ends in Thread::wait

[code]
Thread::wait begin Name:Juce Timer ID:99c

Thread::wait end Name:Juce Timer ID:99c result:0

Thread::wait begin Name:Juce Timer ID:99c

Thread::wait end Name:Juce Timer ID:99c result:0

Thread::wait begin Name:Juce Timer ID:99c

Thread::wait end Name:Juce Timer ID:99c result:0

Thread::wait begin Name:Juce Timer ID:99c

Thread::wait end Name:Juce Timer ID:99c result:0

Thread::wait begin Name:Juce Timer ID:99c <------------
The thread ‘Win32 Thread’ (0x890) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xe08) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xbcc) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xe28) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0xe64) has exited with code 0 (0x0).
The thread ‘Juce Timer’ (0x99c) has exited with code 0 (0x0).

Timer destructor start 315145052 countdownMs=0 isTimerRunning=1 next=0 periodMs=999 previous=0

Timer destructor end 315145052 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0

Timer destructor start 82925372 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0

Timer destructor end 82925372 countdownMs=0 isTimerRunning=0 next=0 periodMs=0 previous=0

Thread::isThreadRunning() Name:Juce Timer ID:99c

Thread::signalThreadShouldExit() Name:Juce Timer ID:99c

Thread::notify() Name:Juce Timer ID:99c

1000x
Thread::isThreadRunning() Name:Juce Timer ID:99c
Thread::isThreadRunning() Name:Juce Timer ID:99c
Thread::isThreadRunning() Name:Juce Timer ID:99c
Thread::isThreadRunning() Name:Juce Timer ID:99c
Thread::isThreadRunning() Name:Juce Timer ID:99c
Cubasesx3.exe has triggered a breakpoint
** Warning - Forced thread termination **

Thread::stopThread Name:Juce Timer ID:0
Thread::isThreadRunning() Name:Juce Timer ID:0
Thread::stopThread Name:Juce Timer ID:0
Thread::~Thread() Name:Juce Timer ID:0
Timer destructor start 82921212 countdownMs=250 isTimerRunning=0 next=0 periodMs=0 previous=0
Timer destructor end 82921212 countdownMs=250 isTimerRunning=0 next=0 periodMs=0 previous=0
Thread::stopAllThreads
Thread::getNumRunningThreads()
Detected memory leaks!
Dumping objects ->
etc…[/code]


#14