Strange crash on OS X


#1

I gave my app to some people for alpha-testing, and here’s a crash that occured under OS X 10.4.11. I don’t think it is my fault - could this be something in JUCE? (any idea Jules?). On Windows, the same app works like a charm, no crashes, never.

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0xd7280fce

Thread 0 Crashed:
0 libobjc.A.dylib 0x90a594c7 objc_msgSend + 23
1 com.apple.HIToolbox 0x92f93de3 HIView::RecursiveDrawComposited(__HIShape const*, unsigned long, HIView*, CGContext*, unsigned char) + 1509
2 com.apple.HIToolbox 0x92f93cfa HIView::RecursiveDrawComposited(__HIShape const*, unsigned long, HIView*, CGContext*, unsigned char) + 1276
3 com.apple.HIToolbox 0x92f944ed HIView::DrawComposited(short, OpaqueGrafPtr*, __HIShape const*, unsigned long, HIView*, CGContext*) + 601
4 com.apple.HIToolbox 0x92e1ca01 HIView::Draw(short, OpaqueGrafPtr*, unsigned long) + 75
5 com.apple.HIToolbox 0x92e1c93d HIView::Render(unsigned long, CGContext*) + 45
6 com.apple.HIToolbox 0x930a4a13 FlushWindowObject(WindowData*, void**, unsigned char) + 581
7 com.apple.HIToolbox 0x92e0e5e5 FlushAllBuffers(__CFRunLoopObserver*, CFRunLoopActivity, void*) + 167
8 com.apple.CoreFoundation 0x9082dce2 __CFRunLoopDoObservers + 342
9 com.apple.CoreFoundation 0x9082d055 CFRunLoopRunSpecific + 1548
10 com.apple.CoreFoundation 0x9082ca42 CFRunLoopRunInMode + 61
11 com.apple.HIToolbox 0x92df1878 RunCurrentEventLoopInMode + 285
12 com.apple.HIToolbox 0x92df0f82 ReceiveNextEventCommon + 385
13 com.apple.HIToolbox 0x92f0799c ReceiveNextEvent + 58
14 com.apple.myCarbonApp 0x00079683 juce::juce_dispatchNextMessageOnSystemQueue(bool) + 165
15 com.apple.myCarbonApp 0x0009112b juce::MessageManager::dispatchNextMessage(bool, bool*) + 71
16 com.apple.myCarbonApp 0x000912c0 juce::MessageManager::runDispatchLoop() + 34
17 com.apple.myCarbonApp 0x0005464b juce::JUCEApplication::main(juce::String&, juce::JUCEApplication*) + 323
18 com.apple.myCarbonApp 0x00054930 juce::JUCEApplication::main(int, char**, juce::JUCEApplication*) + 76
19 com.apple.myCarbonApp 0x00002d23 main + 75
20 com.apple.myCarbonApp 0x00002666 _start + 216
21 com.apple.myCarbonApp 0x0000258d start + 41

Thread 0 crashed with X86 Thread State (32-bit):
eax: 0xd7280fce ebx: 0x9080df7d ecx: 0x90ac0010 edx: 0x00000000
edi: 0xd7280fd6 esi: 0x18e47e40 ebp: 0xbfffefc8 esp: 0xbfffef94
ss: 0x0000001f efl: 0x00010202 eip: 0x90a594c7 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037

Machine: MacBookPro2

And here’s another crash on the same machine:

Thread 3 Crashed:
0 libobjc.A.dylib 0x90a594d1 objc_msgSend + 33
1 com.apple.HIToolbox 0x92e1c56e HIView::Invalidate(__HIShape const*) + 386
2 com.apple.HIToolbox 0x92e3b831 HIViewSetNeedsDisplayInRect + 155
3 com.apple.myCarbonApp 0x001619b4 juce::HIViewComponentPeer::repaint(int, int, int, int) + 236
4 com.apple.myCarbonApp 0x0006f849 juce::Component::repaint() + 93
5 com.apple.myCarbonApp 0x0001bcd6 LevelMeterSlider::setValue(float, bool) + 92
6 com.apple.myCarbonApp 0x00021cc2 MainComponent::midiControlManagerListenerReceive(int, int) + 72
7 com.apple.myCarbonApp 0x0005171a MidiControlSurfaceManager::midiIn(juce::MidiMessage const&) + 156
8 com.apple.myCarbonApp 0x000b7d9f juce::AudioDeviceManager::handleIncomingMidiMessageInt(juce::MidiInput*, juce::MidiMessage const&) + 299
9 com.apple.myCarbonApp 0x000cd742 juce::midiInputProc(MIDIPacketList const*, void*, void*) + 906
10 com.apple.audio.midi.CoreMIDI 0x96bb5645 LocalMIDIReceiverList::HandleMIDIIn(void*, void*, MIDIPacketList*) + 195
11 com.apple.audio.midi.CoreMIDI 0x96b90f11 MIDIInPortThread::Run() + 245
12 com.apple.audio.midi.CoreMIDI 0x96b91b6d XThread::RunHelper(void*) + 17
13 com.apple.audio.midi.CoreMIDI 0x96b994ad CAPThread::Entry(CAPThread*) + 93
14 libSystem.B.dylib 0x90024227 _pthread_body + 84

Thread 3 crashed with X86 Thread State (32-bit):
eax: 0x08558be4 ebx: 0x9080df7d ecx: 0x90ac0010 edx: 0x24000000
edi: 0x08558bec esi: 0xff000000 ebp: 0xb021fb38 esp: 0xb021fb04
ss: 0x0000001f efl: 0x00010206 eip: 0x90a594d1 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037

Here 2 debugger outputs:

[Session started at 2008-07-01 12:25:17 +0000.]
CoreMidi - opening inp: Port 1
juce_application(1238,0xa000d000) malloc: *** error for object 0x580ac0: double free
juce_application(1238,0xa000d000) malloc: *** set a breakpoint in szone_error to debug
juce_application(1238,0xa000d000) malloc: *** error for object 0x57e220: double free
juce_application(1238,0xa000d000) malloc: *** set a breakpoint in szone_error to debug

juce_application has exited with status 0.
[Session started at 2008-07-01 12:32:25 +0000.]
CoreMidi - opening inp: Port 1
juce_application(1619,0xa000d000) malloc: *** error for object 0x1d98d6c: Non-aligned pointer being freed
juce_application(1619,0xa000d000) malloc: *** set a breakpoint in szone_error to debug


#2

Looks like you’re doing some dodgy multi-threading there - you really shouldn’t call UI methods on a thread other than the main event thread.


#3

I think it has to do with the fact that I called repaint() in one of my components. I took care not to call repaint() but only my own setDirty() which is Thread-safe, but it seems I missed that one.


#4

Hi all,

sometimes I had the same strange crashes, when I call repaint() from a Thread on MAC. Now I replaced the Thread with a Timer and it seems to be stable.

My question is: Does the Timer run in the Main GUI Thread like the Swing Timers in Java?

That´s the only possible explanation for me.

Regards,
Rüdi


#5

Hi Rüdi,

You are right, the timer callbacks take place in the main GUI thread.
I used to resynchronize them using a PostMessage, then I realize in the Juce doc that this was part of the Timer class spec.

Regards,
Robert


#6

Hi Robert,

thanks for the answer. So I can hope there will be no crash anymore!

Regards,
Rüdi