Strange bug


#1

When my application (or other applications) scans the JUCE AudioUnit Demo from JUCE 1.46, it crashes:

Exception: EXC_ARITHMETIC (0x0003)
Codes: EXC_I386_DIV (divide by zero)

Thread 0 Crashed:
0 …materialsoftware.JuceAUDemo 0x1bf7640d juce::ArrayAllocationBase<juce::MessageListener const*>::ensureAllocatedSize(int) + 37
1 …materialsoftware.JuceAUDemo 0x1bf7646d juce::SortedSet<juce::MessageListener const*, juce::DummyCriticalSection>::insertInternal(int, juce::MessageListener const*) + 29
2 …materialsoftware.JuceAUDemo 0x1bf76504 juce::SortedSet<juce::MessageListener const*, juce::DummyCriticalSection>::add(juce::MessageListener const*) + 96
3 …materialsoftware.JuceAUDemo 0x1bedc780 juce::MessageListener::MessageListenernot-in-charge + 50
4 …materialsoftware.JuceAUDemo 0x1bf75e70 juce::AsyncUpdater::AsyncUpdaterInternal::AsyncUpdaterInternalin-charge + 24
5 …materialsoftware.JuceAUDemo 0x1bed6ed9 juce::AsyncUpdater::AsyncUpdaternot-in-charge + 35
6 …materialsoftware.JuceAUDemo 0x1bed39d6 juce::desktop::Desktopin-charge + 46
7 …materialsoftware.JuceAUDemo 0x1bed3aa3 juce::desktop::getInstance() + 45
8 …materialsoftware.JuceAUDemo 0x1bef1421 juce::LookAndFeel::setDefaultLookAndFeel(juce::LookAndFeel*) + 75
9 …materialsoftware.JuceAUDemo 0x1bed0fe7 juce::initialiseJuce_GUI() + 55
10 …materialsoftware.JuceAUDemo 0x1bf675c7 JuceAU::JuceAU[in-char

The PluginHost also crashes in ArrayAllocationBase (but only in Release build, not in Debug), so there seems to be something wrong there.


#2

I’ve changed so many things since then that I’ve no idea whether this was one of them! Presumably it’s no longer an issue, because my AUs seem to work ok.


#3

also happens when compiling standalone apps.


#4

…but presumably not in the AU code. And obviously if it crashed during the initialiseJuce_GUI then no apps at all would ever run… Have you just got some sort of link problem?


#5

No it’s not in the AU code. The problem is a division by zero in ensureAllocatedSize() although this should never happen. Well, I don’t know, it works in Debug build, but never in Release build. Also when compiling the PluginHost without any change in Release, it just crashes.


#6

Presumably it’s crashing because the granularity value is 0, which can only have happened if the object was dangling - so I guess in debug you get away with it because the debugger has put non-zero values into the deleted object. Can’t think why this’d happen, but don’t want to spend much time on it unless you can show it still happens with the tip code.


#7

That’s correct. When I build the Release with Debug Symbols, everything works fine. Without Debug Symbols, there’s the crash. I’ll try with 1.47, if it compiles here (I never achieved to compile it before).


#8

Ok, PluginHost still crashes with the tip. Tried today. I’m not using the amalgamated version of JUCE though, because my XCode2.5 generates an internal compiler error. Here’s what happens when I start the PluginHost (Release build):

#0 0xffff01a4 in objc_msgSend_rtp
#1 0x0000000a in ??
#2 0x000b7a5d in juce::ReferenceCountedObject::incReferenceCount at juce_ReferenceCountedObject.h:77
#3 0x000b7d6e in juce::ReferenceCountedObjectPtrjuce::AudioProcessorGraph::Node::ReferenceCountedObjectPtr at juce_ReferenceCountedObject.h:153
#4 0x00002f43 in FilterGraph::getNode at FilterGraph.cpp:100
#5 0x00005524 in GraphEditorPanel::updateComponents at GraphEditorPanel.cpp:861
#6 0x000057fd in GraphDocumentComponent::GraphDocumentComponent at GraphEditorPanel.cpp:1055
#7 0x0000720f in MainHostWindow::MainHostWindow at MainHostWindow.cpp:99
#8 0x000bb323 in PluginHostApp::initialise at HostStartup.cpp:73
#9 0x0003d2d7 in juce::JUCEApplication::main at HostStartup.cpp:117
#10 0x0003d4c7 in juce::JUCEApplication::main at HostStartup.cpp:117
#11 0x00007734 in main at HostStartup.cpp:117

This was without AU/VST hosting support.
[JUCE Demo works ok by the way]

With AU hosting support I get:

#0 0x000c111a in juce::GraphRenderingOps::RenderingOpSequenceCalculator::createRenderingOpsForNode at GraphEditorPanel.cpp:306
#1 0x000c1618 in juce::GraphRenderingOps::RenderingOpSequenceCalculator::RenderingOpSequenceCalculator at GraphEditorPanel.cpp:306
#2 0x000107d1 in juce::AudioProcessorGraph::buildRenderingSequence at HostStartup.cpp:117
#3 0x00010d49 in juce::AudioProcessorPlayer::setProcessor at HostStartup.cpp:117
#4 0x000111de in juce::AudioProcessorPlayer::audioDeviceAboutToStart at HostStartup.cpp:117
#5 0x00027cec in juce::AudioDeviceManager::setAudioCallback at HostStartup.cpp:117
#6 0x0000624f in GraphDocumentComponent::GraphDocumentComponent at GraphEditorPanel.cpp:1053
#7 0x00007c6f in MainHostWindow::MainHostWindow at MainHostWindow.cpp:99
#8 0x000be6f3 in PluginHostApp::initialise at HostStartup.cpp:73
#9 0x0003de43 in juce::JUCEApplication::main at HostStartup.cpp:117
#10 0x0003e033 in juce::JUCEApplication::main at HostStartup.cpp:117
#11 0x00008194 in main at HostStartup.cpp:117

Again, the Debug build works flawlessly! It’s always the Release build of PluginHost that crashes.


#9

Jules, do you have any idea why this crash?


#10

Nothing springs to mind by looking at the stack trace… I’d need to have a proper debugging session to figure it out, but am busy on some other stuff right now…


#11

Has this ever been resolved? Because I’m experiencing a crash at basically the same point in a plugin version of the host that I’m building at the moment…


#12

Don’t think I looked at it yet.


#13

I first get a “pointer being freed was not allocated” which, after using malloc_error_break, comes from AudioProcessorGraph::addNode (couldn’t find the respective “free” in there yet), then a bit later it crashes in AudioProcessorGraph::getNode. Everything works fine in Debug mode. Additionally, Release mode also works if I don’t link against the Release but against the Debug version of the JUCE library. So it seems to be related to the array memory management in JUCE somehow, but the difficulty to debug this has stopped me from getting any further insight so far. It’s on Snow Leopard with the latest trunk, btw.