identifierForVendor crash as EXC_BAD_ACCESS

I have hit that issue not very frequently and all version of hit issues are more than IOS 11.

This is one of crash log:

OS Version: iPhone OS 11.1.2 (15B202)

Baseband Version: n/a

Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV)

Exception Subtype: KERN_INVALID_ADDRESS at 0x00000101831801e0

VM Region Info: 0x101831801e0 is not in any region. Bytes after previous region: 1097952920033

REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL MALLOC_NANO (reserved) 00000001d8000000-00000001e0000000 [128.0M] rw-/rwx SM=NUL ...(unallocated)

--->
UNUSED SPACE AT END

Termination Signal: Segmentation fault: 11

Termination Reason: Namespace SIGNAL, Code 0xb

Terminating Process: exc handler [0]

Triggered by Thread: 0

Filtered syslog:

None found

Thread 0 name: Dispatch queue: com.apple.main-thread

Thread 0 Crashed:

0 ??? 0x00000101831801e0 0 + 1106005983712

1 MobileCoreServices 0x0000000183188af0 -[LSApplicationWorkspace deviceIdentifierForVendor] + 192

2 UIKit 0x000000018ad5cd48 -[UIDevice identifierForVendor] + 56

3 Test-Demo-iOS 0x000000010073cc4c __35+[ getInstance_:vendorKey:]_block_invoke + 160

4 libdispatch.dylib 0x0000000180d75048 _dispatch_client_callout + 16

5 libdispatch.dylib 0x0000000180d78710 dispatch_once_f$VARIANT$mp + 60

...

This code appeared in the beginning of viewDidLoad. And in getInstance_, my original code is:

  c_inst->dbg("_device_id", [[[[UIDevice currentDevice] identifierForVendor] UUIDString]UTF8String]);

This code can hit this crash issue. And I made some changes but still failed to avoid this crash:

  UIDevice *device = [UIDevice currentDevice];
  if (device){
      NSUUID *idfv = [device identifierForVendor]; 
      if (idfv){
          c_inst->dbg("_device_id", [[idfv UUIDString] UTF8String]); 
      }
  }

Have anybody hit this issue and know the root cause for that crash? I also need someone help give me some suggestions that fix this issue.

Thanks

The problem is either the Objective C or the C.

I know nothing about "c_inst->dbg()" but the rest should work fine.

Try it without that and see if it works.

identifierForVendor crash as EXC_BAD_ACCESS
 
 
Q