Host crashes after deleting the plugin


#1

Well i know this issue has been posted some time ago i just wanted to find out if there is a workaround that someone has come up with.
So far i’ve tried separating my VST/AU projects in the Introjucer, but that didn’t help. Once i delete the plugin, Live goes on working
but after some time (a few seconds so it’s quite a long time) it crashes with

#0	0x9102b09a in mach_msg_trap
#1	0x9102b807 in mach_msg
#2	0x976eb37f in __CFRunLoopRun
#3	0x976ea464 in CFRunLoopRunSpecific
#4	0x976ea291 in CFRunLoopRunInMode
#5	0x98f44e04 in RunCurrentEventLoopInMode
#6	0x98f44bb9 in ReceiveNextEventCommon
#7	0x98f44a3e in BlockUntilNextEventMatchingListInMode
#8	0x92cbe78d in _DPSNextEvent
#9	0x92cbdfce in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
#10	0x92c80247 in -[NSApplication run]
#11	0x014abbc2 in std::out_of_range::~out_of_range
#12	0x014a7cde in std::out_of_range::~out_of_range

i assume it’s the bug where the OS or the HOST tries to deliver some messages to a non-existing plugin.

I added a line like so

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

in my plugin destructor, but that doesn’t help either. Does anyone have any other ideas for this. Without a fix for this the AudioPlugin wrapper is unusable really.

My tests are on OSX 10.6.7 with Live8 and Maschine

Maschine debugger output when crashing

CtrlrProcessor::dtor
[Switching to process 3509]
Program received signal:  “EXC_BAD_ACCESS”.
[Switching to process 3509]
sharedlibrary apply-load-rules all
warning: Could not find object file "/Users/developer/CVS/external/coreaudio-sdk-1.5-R2/lib/osx/libcoreaudio-sdk-ni.a(CAComponent.o)" - no debug information available for "/Users/fdetro/Development/CVS/external/coreaudio-sdk-1.5-R2/PublicUtility/CAComponent.cpp".

warning: Could not find object file "/Users/developer/CVS/external/coreaudio-sdk-1.5-R2/lib/osx/libcoreaudio-sdk-ni.a(CAAudioUnit.o)" - no debug information available for "/Users/fdetro/Development/CVS/external/coreaudio-sdk-1.5-R2/PublicUtility/CAAudioUnit.cpp".

warning: .o file "/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_eprintf.o)" more recent than executable timestamp in "/Applications/Native Instruments/Maschine/Maschine.app/Contents/MacOS/Maschine"
warning: Could not open OSO file /Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_eprintf.o) to scan for pubtypes for objfile /Applications/Native Instruments/Maschine/Maschine.app/Contents/MacOS/Maschine
warning: Could not find object file "/Users/developer/CVS/external/coreaudio-sdk-1.5-R2/lib/osx/libcoreaudio-sdk-ni.a(CAComponentDescription.o)" - no debug information available for "/Users/fdetro/Development/CVS/external/coreaudio-sdk-1.5-R2/PublicUtility/CAComponentDescription.cpp".

warning: Could not find object file "/Users/developer/CVS/external/coreaudio-sdk-1.5-R2/lib/osx/libcoreaudio-sdk-ni.a(CAAudioChannelLayoutObject.o)" - no debug information available for "/Users/fdetro/Development/CVS/external/coreaudio-sdk-1.5-R2/PublicUtility/CAAudioChannelLayoutObject.cpp".

warning: Could not find object file "/Users/developer/CVS/external/coreaudio-sdk-1.5-R2/lib/osx/libcoreaudio-sdk-ni.a(AUOutputBL.o)" - no debug information available for "/Users/fdetro/Development/CVS/external/coreaudio-sdk-1.5-R2/PublicUtility/AUOutputBL.cpp".

warning: Could not find object file "/Users/developer/CVS/external/coreaudio-sdk-1.5-R2/lib/osx/libcoreaudio-sdk-ni.a(CAAudioChannelLayout.o)" - no debug information available for "/Users/fdetro/Development/CVS/external/coreaudio-sdk-1.5-R2/PublicUtility/CAAudioChannelLayout.cpp".

warning: Could not find object file "/Users/developer/CVS/external/elastiquePro-2.1.1-R3/lib/osx/libzplVecLib.a(zplVecLibDispatch.o)" - no debug information available for "/Users/flea2/Development/zplane/elastiquePro/build/../src/zplVecLib/zplVecLibDispatch.cpp".

warning: Could not find object file "/Users/developer/CVS/external/elastiquePro-2.1.1-R3/lib/osx/libzplVecLib.a(zplVecLibAltiVec.o)" - no debug information available for "/Users/flea2/Development/zplane/elastiquePro/build/../src/zplVecLib/zplVecLibAltiVec.cpp".

warning: Could not find object file "/Users/developer/CVS/external/elastiquePro-2.1.1-R3/lib/osx/libzplVecLib.a(zplFFTAltiVec.o)" - no debug information available for "/Users/flea2/Development/zplane/elastiquePro/build/../src/zplVecLib/zplFFTAltiVec.cpp".

warning: Could not find object file "/Users/developer/CVS/external/elastiquePro-2.1.1-R3/lib/osx/libzplVecLib.a(zplVecLibGen.o)" - no debug information available for "/Users/flea2/Development/zplane/elastiquePro/build/../src/zplVecLib/zplVecLibGen.cpp".

warning: Could not find object file "/Users/developer/CVS/external/elastiquePro-2.1.1-R3/lib/osx/libzplVecLib.a(zplFFT_If.o)" - no debug information available for "/Users/flea2/Development/zplane/elastiquePro/build/../src/zplVecLib/zplFFT_If.cpp".

and the stack trace

#0	0x976baf10 in CFRelease
#1	0x93ec813c in HTTPMessage::~HTTPMessage
#2	0x976bb101 in _CFRelease
#3	0x93ef2fe6 in HTTPWriteFilter::~HTTPWriteFilter
#4	0x976bb101 in _CFRelease
#5	0x976e633c in __CFStreamDeallocate
#6	0x976bb101 in _CFRelease
#7	0x93ef2e79 in NetConnection::shutdownConnectionStreams
#8	0x93f31d58 in NetConnection::closeStreamsIfPossibleOrSignalThatThatNeedsToBeDonePrettyPlease
#9	0x93f01843 in NetConnection::doNotAllowMoreReqeusts
#10	0x93f4413b in UnauthConnectionArray::removeValueAtIndex
#11	0x93f41d3d in HTTPConnectionCacheEntry::removeAllConnections
#12	0x93f41aef in HTTPConnectionCacheDictionary::forgetCacheEntries
#13	0x93f41b32 in ConnectionCacheTLS::resetCacheForThisThread
#14	0x93edaf6c in ConnectionTimerTLS::_timerPurgeEntries
#15	0x976ecadb in __CFRunLoopRun
#16	0x976ea464 in CFRunLoopRunSpecific
#17	0x976ea291 in CFRunLoopRunInMode
#18	0x94c5e6f4 in +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:]
#19	0x94c25ad0 in -[NSThread main]
#20	0x94c25a80 in __NSThread__main__
#21	0x910587fd in _pthread_start
#22	0x91058682 in thread_start

#2

I’m seeing a similar crash in an unrelated, non-Juce project. I found this post by accident when searching for function names from my crash stack trace, which is nearly identical to yours. I figured out my problem and got an account here so that I could post the answer in case it’s helpful.

In my case, the crash would happen when I used the NSURLConnection API’s from within a shared library, then unloaded the shared library. The crash occurred because when Apple’s timer thread runs later (apparently to do some cleanup), it tries to access an NSString constant that I provided to the NSMutableURLRequest. But if the shared library is unloaded when this happens, the result is an access error because the string constant is located in the data section of my shared library binary.

The work around was to dynamically allocate all NSStrings provided to the NSURLConnection and related API’s. So instead of passing a @“POST” constant directly, for example, pass a copy of the constant that you’ve allocated yourself. Here’s a code example snippet, including my comments on this complex problem:

	// WARNING! Do not use NSString constants (i.e. @"POST") here because when this
	// code is built into a shared library, some NSURL timer proc tries to reference the 
	// constant in our data section. This results in an  access violation if the shared lib
	// where this code lives has been unloaded.
	// Wot-A-Hack ;-)
	NSString* postString = [NSString stringWithUTF8String:"POST"];
	[post setHTTPMethod: postString];

Of course you have to do the same for all constants you provide to the API.

Hopefully the above info will help you work around your problem.

Best,

Allen Cronce


#3

Wow. Thanks for sharing that, Allen!

I guess I should have a quick search through the codebase for obj-C literals that might also cause trouble… It’s incredible how much trouble the obj-C linkage mechanism causes!


#4

Hey Everyone,

I know this is an old post, however, I found it searching for a similar stack trace. I believe I may have stumbled upon this crash in the URL class. It happens highly infrequently, potentially every couple hundred runs…, but I believe it stems from functions in the webInputStream class.

Perhaps the issue is something similar to what Allen described.

the crash happens occasionally upon this request for the HTTP Body using the NSURLRequest class, it is a SIGABRT error:

 while (isThreadRunning() && ! initialised)
        {
            if (callback != nullptr)
             CRASH HERE: if (! callback (context, (int) latestTotalBytes, (int) [[request HTTPBody] length]))
                    return false;
            
            Thread::sleep (1);
        } 

This falls out from the createConnection function where the NSMutableURLRequest is constructed at the beginning

        if (NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: juceStringToNS (address)]
                                                               cachePolicy: NSURLRequestReloadIgnoringLocalCacheData
                                                           timeoutInterval: timeOutMs <= 0 ? 60.0 : (timeOutMs / 1000.0)])

it’s setHTTPMethod is called with an inline NSString constructor:

[req setHTTPMethod: [NSString stringWithUTF8String: httpRequestCmd.toRawUTF8()]];

At first I thought the issue may be stemming from all of the references being passed into web input stream, but most of them are passed to copy constructors.

Currently i’m giving this a shot, similar to what Allen had recommended :

NSString* commandString = [NSString stringWithUTF8String: httpRequestCmd.toRawUTF8()];
[req setHTTPMethod: commandString];

Although I’m not positive this will have any affect… obj-c is not a strength of mine…

The issue is hard to track though due to how infrequently it occurs. I will continue to attempt repro, but if anyone on the JUCE team had a chance to check out the code with what Allen had in mind, or if there was a way to make the code fail without crashing, that would be great moving forward.

Best,

Jake