novastone-media / MQTT-Client-Framework

iOS, macOS, tvOS native ObjectiveC MQTT Client Framework
Other
1.84k stars 466 forks source link

SIGABRT ABORT when [NSManagedObjectContext executeFetchRequest:error:] #465

Closed Dingo203 closed 5 years ago

Dingo203 commented 6 years ago

I used latest version of MQTT-Client-Framework in my app and I found some occasional core data crash on Fabric. When the method [MQTTCoreDataPersistence allFlowsforClientId:incomingFlag:] was called may lead occasional core data crash at [NSManagedObjectContext executeFetchRequest:error:]. And I don't know what case would lead to this problem.

Crashed: SQLQueue 0x135e54a00 for MQTTClient
0  libsystem_kernel.dylib         0x1856c3014 __pthread_kill + 8
1  libsystem_pthread.dylib        0x18578b450 pthread_kill + 112
2  libsystem_c.dylib              0x185637400 abort + 140
3  libsystem_malloc.dylib         0x185707a5c _nano_vet_and_size_of_live + 330
4  libsystem_malloc.dylib         0x185709028 nano_realloc + 648
5  libsystem_malloc.dylib         0x1856fb240 malloc_zone_realloc + 180
6  libsqlite3.dylib               0x186c30c34 (null) + 1224
7  libsqlite3.dylib               0x186c77f38 (null) + 1568
8  libsqlite3.dylib               0x186c8df78 (null) + 91744
9  libsqlite3.dylib               0x186c11714 (null) + 35120
10 libsqlite3.dylib               0x186bebcb0 (null) + 10664
11 libsqlite3.dylib               0x186beb608 (null) + 8960
12 libsqlite3.dylib               0x186bea838 (null) + 5424
13 libsqlite3.dylib               0x186be9f24 (null) + 3100
14 libsqlite3.dylib               0x186be9ae0 (null) + 2008
15 CoreData                       0x1889f1284 -[NSSQLiteConnection prepareSQLStatement:] + 472
16 CoreData                       0x188b18860 -[NSSQLiteConnection selectRowsWithStatement:cached:] + 60
17 CoreData                       0x188b283a8 newFetchedRowsForFetchPlan_MT + 1112
18 CoreData                       0x188bbe8d0 _executeFetchRequest + 72
19 CoreData                       0x188bb9b64 -[NSSQLFetchRequestContext executeRequestUsingConnection:] + 60
20 CoreData                       0x188acdaf8 __52-[NSSQLDefaultConnectionManager handleStoreRequest:]_block_invoke + 260
21 libdispatch.dylib              0x18557e1bc _dispatch_client_callout + 16
22 libdispatch.dylib              0x18558b7f0 _dispatch_barrier_sync_f_invoke + 84
23 CoreData                       0x188acd994 -[NSSQLDefaultConnectionManager handleStoreRequest:] + 208
24 CoreData                       0x188b93f80 -[NSSQLCoreDispatchManager routeStoreRequest:] + 288
25 CoreData                       0x188afb7e4 -[NSSQLCore dispatchRequest:withRetries:] + 200
26 CoreData                       0x188af7d90 -[NSSQLCore processFetchRequest:inContext:] + 108
27 CoreData                       0x1889f826c -[NSSQLCore executeRequest:withContext:error:] + 504
28 CoreData                       0x188ada7e0 __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 4512
29 CoreData                       0x188ad2bf0 -[NSPersistentStoreCoordinator _routeHeavyweightBlock:] + 276
30 CoreData                       0x1889f7f20 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 408
31 CoreData                       0x1889f6908 -[NSManagedObjectContext executeFetchRequest:error:] + 572
32 app                          0x100c76a28 __65-[MQTTCoreDataPersistence allFlowsforClientId:incomingFlag:]_block_invoke (MQTTCoreDataPersistence.m:309)
33 CoreData                       0x188a9de98 developerSubmittedBlockToNSManagedObjectContextPerform + 152
34 libdispatch.dylib              0x18557e1bc _dispatch_client_callout + 16
35 libdispatch.dylib              0x18558b7f0 _dispatch_barrier_sync_f_invoke + 84
36 CoreData                       0x188a9dda8 -[NSManagedObjectContext performBlockAndWait:] + 308
37 app                          0x100c766d8 -[MQTTCoreDataPersistence allFlowsforClientId:incomingFlag:] (MQTTCoreDataPersistence.m:299)
38 app                          0x100c7ddf8 -[MQTTSession checkTxFlows] (MQTTSession.m:626)
jcavar commented 6 years ago

Is there an exception message in debugger for this?

Dingo203 commented 6 years ago

Sorry to tell that I can't reproduce this case when debugging this problem, it seems quite normal and there is no exception. I can only see this reported on Fabric, which occurrence probability is about one thousandth.

jcavar commented 6 years ago

Which version of the library are you using?

Dingo203 commented 6 years ago

version 0.14.0

jcavar commented 5 years ago

Is this still happening with latest version of the library?

fantexi023 commented 2 years ago

Hi, I met the similar problem. the call stack is following:

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: 0x00000000 at 0x0000000000000000 Crashed Thread: 51

// 崩溃线程 Thread 51 Crashed: 0 CoreData _fetchResultSetAllocateInitialize 1 CoreData _fetchResultSetAllocateInitialize 2 CoreData _newFetchedRowsForFetchPlan_MT 3 CoreData executeFetchRequest 4 CoreData -[NSSQLFetchRequestContext executeRequestCore:] 5 CoreData -[NSSQLStoreRequestContext executeRequestUsingConnection:] 6 CoreData ___52-[NSSQLDefaultConnectionManager handleStoreRequest:]_blockinvoke 7 CoreData 37-[NSSQLiteConnection performAndWait:]_block_invoke 8 libdispatch.dylib dispatch_client_callout 9 libdispatch.dylib dispatch_lane_barrier_sync_invoke_and_complete 10 CoreData -[NSSQLiteConnection performAndWait:] 11 CoreData -[NSSQLDefaultConnectionManager handleStoreRequest:] 12 CoreData -[NSSQLCoreDispatchManager routeStoreRequest:] 13 CoreData -[NSSQLCore dispatchRequest:withRetries:] 14 CoreData -[NSSQLCore executeRequest:withContext:error:] 15 CoreData _65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke.657 16 CoreData -[NSPersistentStoreCoordinator _routeHeavyweightBlock:] 17 CoreData -[NSPersistentStoreCoordinator executeRequest:withContext:error:] 18 CoreData -[NSManagedObjectContext executeFetchRequest:error:] 19 HLLMQTTClient 60-[MQTTCoreDataPersistence allFlowsforClientId:incomingFlag:]_block_invoke MQTTCoreDataPersistence.m:321 20 CoreData _developerSubmittedBlockToNSManagedObjectContextPerform 21 libdispatch.dylib dispatch_client_callout 22 libdispatch.dylib dispatch_lane_barrier_sync_invoke_and_complete 23 CoreData -[NSManagedObjectContext performBlockAndWait:] 24 HLLMQTTClient -[MQTTCoreDataPersistence allFlowsforClientId:incomingFlag:] MQTTCoreDataPersistence.m:311 25 HLLMQTTClient -[MQTTSession checkTxFlows] MQTTSession.m:633 26 HLLMQTTClient 41-[MQTTSession decoder:didReceiveMessage:]_block_invoke MQTTSession.m:804 27 libdispatch.dylib dispatch_client_callout 28 libdispatch.dylib dispatch_continuation_pop$VARIANT$armv81 29 libdispatch.dylib dispatch_source_invoke$VARIANT$armv81 30 libdispatch.dylib __dispatch_lane_serial_drain$VARIANT$armv81 31 libdispatch.dylib dispatch_lane_invoke$VARIANT$armv81 32 libdispatch.dylib dispatch_workloop_worker_thread 33 libsystem_pthread.dylib __pthread_wqthread

hope to fix it

fantexi023 commented 2 years ago

@jcavar sorry ,just notice that the issue was closed.my version is very new