Crash on App Start-Up

I need help debugging an issue where the app I am developing crashes on start-up about once every five or six times I start it. The line of code that crashes is this:

page[pageToSet].parameter[parameterToSet].source = source

both the [parameterToSet].source and local "source" variable are defined as Strings and the value of "source" is "i ". This should be fine, yet, it crashes.

I followed xCode's recommendation to, "set a breakpoint in malloc_error_break to debug" and the next time my app crashed it reported:

libsystem_malloc.dylib`malloc_error_break:

->  0x19d215cd8 <+0>:  pacibsp      0x19d215cdc <+4>:  stp    x29, x30, [sp, #-0x10]!     0x19d215ce0 <+8>:  mov    x29, sp     0x19d215ce4 <+12>: nop         0x19d215ce8 <+16>: ldp    x29, x30, [sp], #0x10     0x19d215cec <+20>: retab

Which is gibberish to me...

Help?

Replies

Hi, have you taken a look at a crash log for your app? Sometimes those contain additional info about the crash. You can find info about getting crash logs from iOS here.

Alternatively, you could add in assert statements to ensure that your dictionaries are not nil and that the keys are contained within the dictionary. Also, how is pageToSet generated?

It looks like the pacibsp instruction is a pointer authentication instruction https://developer.arm.com/documentation/dui0801/h/mpg1476202746202

"pageToSet" and "parameterToSet" are passed in as integers. I checked their values when the code crashes and both are valid numbers (pageToSet is 2, parameterToSet is 1, and source is "i "). Next time it blows up I'll try and get the crash log. Here is the whole function:

public func updateParameterStatus(pageToSet: Int, parameterToSet: Int, source: String){

    if  (pageToSet >= 1) && (pageToSet <= 10) && (parameterToSet >= 1) && (parameterToSet <= 20){

        page[pageToSet].parameter[parameterToSet].source = source // this line crashes sometimes on start up for some reason

        if source == "t "{             page[pageToSet].parameter[parameterToSet].isComputed = true         } else {             page[pageToSet].parameter[parameterToSet].isComputed = false         }

               page[pageToSet].parameter[parameterToSet].timeStamp = N777.currentTime.timeIntervalSinceReferenceDate         page[pageToSet].parameter[parameterToSet].isValid = true         page[pageToSet].parameter[parameterToSet].isStale = false

                 if source == "i " || source == "d " {             page[pageToSet].parameter[parameterToSet].isImported = true         } else {             page[pageToSet].parameter[parameterToSet].isImported = false         }

        page[pageToSet].parameter[parameterToSet].hasBeenEntered = true     } }