Exception Type: EXC_BAD_ACCESS (SIGSEGV), Exception Subtype: KERN_INVALID_ADDRESS at 0x0.. -> 0x.. (possible pointer authentication failure)

This is code block lead to crash to my app, the array of contacts is about 1 million elements, how can i solve this, thank you all:

struct Contact {
  let blIdContact: String
  let timeStamp: Int64
}
func binarySearch(in contacts: [Contact], for value: String) -> Int? {
  var left = 0
  var right = contacts.count - 1
  while left <= right {
    let middle = Int(floor(Double(left + right) / 2.0))
    if contacts[middle].blIdContact < value {
      left = middle + 1
    } else if contacts[middle].blIdContact > value {
      right = middle - 1
    } else {
      return middle
    }
  }
  return nil
}

I have a crash with backtrace:

Answered by DTS Engineer in 688384022

I suspect I know what’s going on here. Consider this:

Thread 9 name:
Thread 9:
0   libsystem_kernel.dylib        	0x00000001b1a6464c write + 8
1   Bluezone                      	0x0000000100bf8ad4 CLSSDKFileLog + 288
2   Bluezone                      	0x0000000100bf07c4 CLSMachExceptionServer + 904
3   libsystem_pthread.dylib       	0x00000001cf5bbcb0 _pthread_start + 320 (pthread.c:881)
4   libsystem_pthread.dylib       	0x00000001cf5c4778 thread_start + 8

This indicates that you’re using a third-party crash reporter. I suspect that either:

  • This crash report is from that third-party crash reporter, and it’s reporting incorrect results, or

  • This crash report is from the Apple crash reporter, but the third-party crash reporter has caused it to generate incorrect results

Either way, I can’t help you with this. You should remove that third-party crash reporter and, if the problem persists, post an Apple crash report.

See Posting a Crash Report for information on how best to post a crash report.

See Implementing Your Own Crash Reporter for an in-depth discussion of the problems with third-party crash reporters.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Are you sure that this symbolicated correctly? Consider the top of your crashing thread:

Thread 12 name:
Thread 12 Crashed:
0   Bluezone        0x000000010084d420 binarySearch(in:for:) + 37920 (Utils.swift:46)

The function offset is 37920, which is way more than I’d expect to see for the code you posted.

By way of comparison, when I compiled your binarySearch(in:for:) function with Xcode 13.0 RC, the code size was 905 bytes in the Debug build and 353 bytes in the Release build.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

This is block of code illustrate how i call binarySearch(in:for:) : the binarySearch(in:for:) function is not belong to any class and can call directly any where

public class ScannerManagerCovid {
   func checkContactF() {
    let dispatch = DispatchQueue(label: "Bluezone.Trace")
    dispatch.async {
      let result = BluezoneIdTrace.checkContactF()
      resolve(result)
    }
}

class BluezoneIdTrace {
    static func checkContactF() {
         let indexfinded = binarySearch(in: contacts, for: bluezoneIdHexString)
         resolve(indexfinded)
    }
}

func binarySearch(in contacts: [Contact], for value: String) -> Int? {
     ...
}
Accepted Answer

I suspect I know what’s going on here. Consider this:

Thread 9 name:
Thread 9:
0   libsystem_kernel.dylib        	0x00000001b1a6464c write + 8
1   Bluezone                      	0x0000000100bf8ad4 CLSSDKFileLog + 288
2   Bluezone                      	0x0000000100bf07c4 CLSMachExceptionServer + 904
3   libsystem_pthread.dylib       	0x00000001cf5bbcb0 _pthread_start + 320 (pthread.c:881)
4   libsystem_pthread.dylib       	0x00000001cf5c4778 thread_start + 8

This indicates that you’re using a third-party crash reporter. I suspect that either:

  • This crash report is from that third-party crash reporter, and it’s reporting incorrect results, or

  • This crash report is from the Apple crash reporter, but the third-party crash reporter has caused it to generate incorrect results

Either way, I can’t help you with this. You should remove that third-party crash reporter and, if the problem persists, post an Apple crash report.

See Posting a Crash Report for information on how best to post a crash report.

See Implementing Your Own Crash Reporter for an in-depth discussion of the problems with third-party crash reporters.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Exception Type: EXC_BAD_ACCESS (SIGSEGV), Exception Subtype: KERN_INVALID_ADDRESS at 0x0.. -&gt; 0x.. (possible pointer authentication failure)
 
 
Q