# Strange crash on OS X

**URL:** <https://forum.juce.com/t/strange-crash-on-os-x/2987>\
**Category:** MacOSX and iOS\
**Created:** [June 27, 2008, 8:33pm UTC](https://forum.juce.com/t/strange-crash-on-os-x/2987 "2008-06-27T20:33:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zamrate](https://avatars.discourse-cdn.com/v4/letter/z/f4b2a3/32.png) [@zamrate](https://forum.juce.com/u/zamrate)\
**Post date:** [June 27, 2008, 8:33pm UTC](https://forum.juce.com/t/strange-crash-on-os-x/2987/1 "2008-06-27T20:33:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 1, 2008, 11:15am UTC](https://forum.juce.com/t/strange-crash-on-os-x/2987/2 "2008-07-01T11:15:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zamrate](https://avatars.discourse-cdn.com/v4/letter/z/f4b2a3/32.png) [@zamrate](https://forum.juce.com/u/zamrate)\
**Post date:** [July 1, 2008, 11:55am UTC](https://forum.juce.com/t/strange-crash-on-os-x/2987/3 "2008-07-01T11:55:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ruedi](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@ruedi](https://forum.juce.com/u/ruedi)\
**Post date:** [August 24, 2008, 9:55am UTC](https://forum.juce.com/t/strange-crash-on-os-x/2987/4 "2008-08-24T09:55:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rbocquier](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@rbocquier](https://forum.juce.com/u/rbocquier)\
**Post date:** [August 26, 2008, 8:12am UTC](https://forum.juce.com/t/strange-crash-on-os-x/2987/5 "2008-08-26T08:12:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ruedi](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@ruedi](https://forum.juce.com/u/ruedi)\
**Post date:** [August 26, 2008, 12:00pm UTC](https://forum.juce.com/t/strange-crash-on-os-x/2987/6 "2008-08-26T12:00:59Z")

</div>

Hi Robert,

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

Regards,  
Rüdi
