registerBasicFormats freeze


#1

When my app loads my synth, it also creates and loads a metronome. Every once in a while (say 1 out of 20) loads it freezes when attempting to load the metronome. The stack trace shows that my last lines of code before it gets into background JUCE and Mac stuff is:

void SynthAudioSource::setMetronomeSound()
{
	metronome.clearSounds();
	AudioFormatManager formatManager;
   formatManager.registerBasicFormats(); // freezes in here....
   //more code....

The registerBasicFormats() method gets called on line #21 of this stack trace:

#0	0x00007fff5fc0b26a in gdb_image_notifier(dyld_image_mode, unsigned int, dyld_image_info const*) ()
#1	0x00007fff5fc0b24d in notifyGDB(dyld_image_states, unsigned int, dyld_image_info const*) ()
#2	0x00007fff5fc0540e in dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) ()
#3	0x00007fff5fc0defa in ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, ImageLoader::RPathChain const&) ()
#4	0x00007fff5fc0565d in dyld::preflight(ImageLoader*, ImageLoader::RPathChain const&) ()
#5	0x00007fff5fc098e7 in dlopen_preflight ()
#6	0x00007fff97948b80 in dlopen_preflight ()
#7	0x00007fff91628a22 in _CFBundleDlfcnPreflight ()
#8	0x00007fff91628879 in CFBundlePreflightExecutable ()
#9	0x00007fff93ff6e97 in AudioComponentPluginLoader::QueryBundle(__CFURL const*, void (*)(void*, AudioComponentDescription const&, __CFString const*, unsigned int, __CFURL const*, __CFBundle*, __CFString const*), void*, __CFArray const**) ()
#10	0x00007fff93f17a58 in AudioComponentPluginLoader::ScanForPluginsInDirectory(char const*) ()
#11	0x00007fff93f174b3 in AudioComponentPluginLoader::ScanForPlugins() ()
#12	0x00007fff93f1732d in AudioComponentPluginMgr::CheckRegistration(unsigned int) ()
#13	0x00007fff93f17138 in AudioComponentPluginMgr::FindNext(OpaqueAudioComponent*, AudioComponentDescription const&) ()
#14	0x00007fff93f16ae6 in _AT_AudioComponentFindNext ()
#15	0x00007fff93f63858 in AudioFileFormatRegistry::AddComponentFormats() ()
#16	0x00007fff93f646e7 in AudioFileFormatRegistry::GetAllExtensions(unsigned int*, void*) ()
#17	0x00007fff93f64f8b in AudioFileGetGlobalInfo ()
#18	0x00000001000efd94 in juce::(anonymous namespace)::findFileExtensionsForCoreAudioCodecs() at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp:39
#19	0x00000001000efcbc in juce::CoreAudioFormat::CoreAudioFormat() at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp:215
#20	0x00000001000e9fa5 in juce::CoreAudioFormat::CoreAudioFormat() at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp:217
#21	0x00000001000e9e71 in juce::AudioFormatManager::registerBasicFormats() at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp:67
#22	0x00000001000662f4 in SynthAudioSource::setMetronomeSound() at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../Source/SynthAudioSource.cpp:70
#23	0x0000000100066191 in SynthAudioSource::SynthAudioSource(juce::MidiKeyboardState&, juce::Slider*, PBSlider*) at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../Source/SynthAudioSource.cpp:47
#24	0x0000000100065dfd in SynthAudioSource::SynthAudioSource(juce::MidiKeyboardState&, juce::Slider*, PBSlider*) at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../Source/SynthAudioSource.cpp:57
#25	0x0000000100084ae7 in SynthComponent::loadSource() at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../Source/SynthComponent.cpp:1958
#26	0x000000010009758c in SourceLoader::run() at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../Source/SynthComponent.h:478
#27	0x00000001001e0f43 in juce::Thread::threadEntryPoint() at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../JuceLibraryCode/modules/juce_core/threads/juce_Thread.cpp:93
#28	0x00000001001e11f5 in juce::juce_threadEntryPoint(void*) at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../JuceLibraryCode/modules/juce_core/threads/juce_Thread.cpp:105
#29	0x00000001001fce6e in threadEntryProc at /Users/Joe/Developer/Syntorial/Builds/MacOSX/../../JuceLibraryCode/modules/juce_core/native/juce_posix_SharedCode.h:838
#30	0x00007fff8db988bf in _pthread_start ()
#31	0x00007fff8db9bb75 in thread_start ()

Any ideas as to what’s going on here? Weird thing is, I pause the app in Xcode to take a look at the stack, and when I unpause it unfreezes and finishes loading. But if I don’t pause/unpause it will just stay frozen forever.


#2

Looks like GDB is crapping out - probably just a GDB bug rather than a bug in the code. Most likely this would never happen when running outside the debugger.


#3

Good to know. Thanks.