OSAtomicIncrement64Barrier crash on 32-bit devices

0

I'm experiencing a crash that only happens on 32-bit devices.

I'm using OSAtomicIncrement64Barrier (on the realtime audio thread) to increment a counter to notify another thread that an update has occurred.

The crash consistently occurs on the OSAtomicIncrement64Barrier line -- but only if it's running while not connected to Xcode.

I don't quite know enough about OSAtomic functions to understand the root of the issue, or if I'm just doing something wrong.

A symbolicated crash report (they all look the same!) for the offending thread is below. Not sure what other information might be necessary to answer this question, so let me know in the comments what else you need to know!

Incident Identifier: 33861B2A-55F9-473A-86FC-BD738CF3A83C
CrashReporter Key:   32b13822728d1015dfd82c926d70db8659f56248
Hardware Model:      iPad3,1
Process:             myApp [413]
Path:                /private/var/mobile/Containers/Bundle/Application/1BEE592E-8F9A-413C-A989-3E39AE3EA407/myApp.app/myApp
Identifier:          ......
Version:             12 (1.0)
Code Type:           ARM (Native)
Parent Process:      launchd [1]

Date/Time:           2015-07-03 19:16:50.193 -0700
Launch Time:         2015-07-03 19:16:35.574 -0700
OS Version:          iOS 8.3 (12F69)
Report Version:      105

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000000
Triggered by Thread:  14


 Thread 14 name:  AURemoteIO::IOThread
Thread 14 Crashed:
0   libsystem_platform.dylib        0x361cdb9e OSAtomicIncrement64Barrier$VARIANT$mp + 6
1   myApp                       0x0008981c renderCallback (ONCAterotAudioController+AudioRenderCallbacks.m:470)
2   AudioToolbox                    0x26f1de8e AUInputElement::PullInput(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long) + 126
3   AudioToolbox                    0x2700523c AUMatrixMixer::Render(unsigned long&, AudioTimeStamp const&, unsigned long) + 556
4   AudioToolbox                    0x27005ddc AUMatrixMixer::RenderBus(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long) + 104
5   AudioToolbox                    0x26e456e6 AUBase::DoRenderBus(unsigned long&, AudioTimeStamp const&, unsigned long, AUOutputElement*, unsigned long, AudioBufferList&) + 142
6   AudioToolbox                    0x26e45578 AUBase::DoRender(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long, AudioBufferList&) + 720
7   AudioToolbox                    0x26e4529a AUMethodRender(void*, unsigned long*, AudioTimeStamp const*, unsigned long, unsigned long, AudioBufferList*) + 42
8   myApp                       0x00088c42 eqCallBack (ONCAterotAudioController+AudioRenderCallbacks.m:115)
9   AudioToolbox                    0x26f1de8e AUInputElement::PullInput(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long) + 126
10  AudioToolbox                    0x26fc8642 AUDynamicsProcessor::Render(unsigned long&, AudioTimeStamp const&, unsigned long) + 298
11  AudioToolbox                    0x26e456e6 AUBase::DoRenderBus(unsigned long&, AudioTimeStamp const&, unsigned long, AUOutputElement*, unsigned long, AudioBufferList&) + 142
12  AudioToolbox                    0x26e45578 AUBase::DoRender(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long, AudioBufferList&) + 720
13  AudioToolbox                    0x26e4529a AUMethodRender(void*, unsigned long*, AudioTimeStamp const*, unsigned long, unsigned long, AudioBufferList*) + 42
14  ONCKit                          0x003f2a5e recordCallback (ONCAudioRecordController.m:106)
15  AudioToolbox                    0x26f16480 AUConverterBase::RenderBus(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long) + 728
16  AudioToolbox                    0x26e456e6 AUBase::DoRenderBus(unsigned long&, AudioTimeStamp const&, unsigned long, AUOutputElement*, unsigned long, AudioBufferList&) + 142
17  AudioToolbox                    0x26e45578 AUBase::DoRender(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long, AudioBufferList&) + 720
18  AudioToolbox                    0x26f0b4b0 AURemoteIO::PerformIO(unsigned long, unsigned int, unsigned int, AudioTimeStamp const&, AudioTimeStamp const&, AudioBufferList const*, AudioBufferList*, int&) + 488
19  AudioToolbox                    0x26f0c566 AURIOCallbackReceiver_PerformIO + 390
20  AudioToolbox                    0x26f047de _XPerformIO + 162
21  AudioToolbox                    0x26e63938 mshMIGPerform + 188
22  AudioToolbox                    0x26edd760 MSHMIGDispatchMessage + 28
23  AudioToolbox                    0x26f0b7bc AURemoteIO::IOThread::Run() + 116
24  AudioToolbox                    0x26f0ee68 AURemoteIO::IOThread::Entry(void*) + 4
25  AudioToolbox                    0x26e416f2 CAPThread::Entry(CAPThread*) + 206
26  libsystem_pthread.dylib         0x361d2de8 _pthread_body + 136
27  libsystem_pthread.dylib         0x361d2d5a _pthread_start + 114
28  libsystem_pthread.dylib         0x361d0b04 thread_start + 4


Thread 14 crashed with ARM Thread State (32-bit):
    r0: 0x00000000    r1: 0x00001294      r2: 0x00000000      r3: 0x00000274
    r4: 0x0b1094e0    r5: 0x0b109c28      r6: 0x0b109634      r7: 0x0b1095ec
    r8: 0x00000000    r9: 0x00000000     r10: 0x00000400     r11: 0x00000400
    ip: 0x3f800000    sp: 0x0b1094e0      lr: 0x00089821      pc: 0x361cdb9e
  cpsr: 0x80000030
ios
multithreading
core-audio
32bit-64bit
asked on Stack Overflow Jul 4, 2015 by olynoise

1 Answer

0

It seems that the issue had to do with alignment issues in my data struct.

Adding

__attribute__ ((aligned (8)))

to the struct that held the counter fixed the issue.

answered on Stack Overflow Jul 4, 2015 by olynoise

User contributions licensed under CC BY-SA 3.0