Post

Replies

Boosts

Views

Activity

Strange Crash When Call performSelector on a new NSThread Object
Crash Stack: Exception Type: SIGSEGV Exception Codes: SEGV_ACCERR at 0x0000cdd42a07c738 Thread 97 Name: BDH_Thread:0x2821c7cc0 Thread 97 Crashed: 0 CoreFoundation 0x00000001813e3cfc __CFGetNonObjCTypeID + 88 1 CoreFoundation 0x000000018140896c _CFRunLoopSourceSignal + 28 2 Foundation 0x0000000182b54484 _performQueueDequeue + 464 3 Foundation 0x0000000182b3dd9c ___NSThreadPerformPerform + 104 4 CoreFoundation 0x0000000181476210 ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 5 CoreFoundation 0x0000000181486238 ___CFRunLoopDoSource0 + 204 6 CoreFoundation 0x00000001813c963c ___CFRunLoopDoSources0 + 356 7 CoreFoundation 0x00000001813cea08 ___CFRunLoopRun + 768 3 CoreFoundation 0x00000001813e1d7c _CFRunLoopRunSpecific + 572 4 CoreFoundation 0x000000018145c260 _CFRunLoopRun + 60 10 QQ 0x00000001047810bc -[BDHUploadManager(Private) runRequests](BDHUploadManager+private.mm:41) 7 Foundation 0x0000000182b66efc ___NSThread__start__ + 792 4 libsystem_pthread.dylib 0x00000001db3873a4 __pthread_start + 116 5 libsystem_pthread.dylib 0x00000001db3859fc _thread_start + 8 Thread 97 crashed with ARM 64 Thread State: x0: 0x0000cdd42a07c730 x1: 0x000000019c8800cc x2: 000000000000000000 x3: 0x0000000000000001 x4: 0x0000000000000010 x5: 0x0000000000000002 x6: 0x0000000280e3d800 x7: 0x00000000ffffffec x8: 0x0000cdd42a07c738 x9: 0x0000000000000013 x10: 0x000000019fb06278 x11: 0x03e700019fb06279 x12: 0x0000000000dd2980 x13: 0x000021a1f29ce831 x14: 0x0000000000000001 x15: 0x00000001f29ce830 x16: 0x00000001f29ce830 x17: 0x00000001813d0c80 x18: 000000000000000000 x19: 0x0000cdd42a07c730 x20: 0x00000001f82d7900 x21: 0x0000000200000003 x22: 0x00000002837e8b70 x23: 0x0000000000000002 x24: 0x00000002821c7cc0 x25: 000000000000000000 x26: 0x00000001f82d7920 x27: 0x00000002821c7d80 80 fp: 0x000000016d23dbc0 lr: 0x000000018140896c _CFRunLoopSourceSignal + 28 0 pc: 0x00000001813e3cfc __CFGetNonObjCTypeID + 88 The Code: [self performSelector:@selector(updateBDHConfigThread:) onThread:[BDHUploadManager instance].uploadThread withObject:dict waitUntilDone:NO]; - (NSThread *)uploadThread { if (!_uploadThread) { _uploadThread = [[NSThread alloc] initWithTarget:self selector:@selector(runRequests) object:nil]; NSString* strThreadName = [NSString stringWithFormat:@"BDH_Thread:%p", _uploadThread]; [_uploadThread setName:strThreadName]; [_uploadThread setThreadPriority:0.6]; [_uploadThread start]; } return _uploadThread; } - (void)runRequests { CFRunLoopSourceContext context = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; CFRunLoopSourceRef source = CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &context); CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode); while (YES) { @autoreleasepool { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; CFRunLoopRun(); [pool release]; } } } Initial analysis: The crash occurs when accessing an address in a x8 register , which should point to a CFRunloopSource object。 The difficulty is that I cannot reproduce it, but there are many reports from online users, so I need help !
5
0
914
Feb ’23