Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoreData Crash on credentialsDAO.addCredential #183

Open
coveloper opened this issue Jan 2, 2025 · 6 comments
Open

CoreData Crash on credentialsDAO.addCredential #183

coveloper opened this issue Jan 2, 2025 · 6 comments
Assignees

Comments

@coveloper
Copy link

Is this a regression?

Yes

Description

I'm trying to process didcommIssueCredential3_0 Messages:

Because Pluto seems to redeliver EVERY message, including Credentials, it seems to crash CoreData.

I've tried calling processIssuedCredentialMessage from Main or Task.detached and it seems to crash each time. Threading issue? or am I just "holding it wrong"?

Image Image

This is something I found related to the error I'm seeing: https://stackoverflow.com/questions/44963142/how-to-fix-attempt-to-recursively-call-save-error-with-coredata

Please provide the exception or error you saw

Error Domain=NSCocoaErrorDomain Code=132001 "(null)" UserInfo={message=attempt to recursively call -save: on the context aborted, stack trace=(
	0   CoreData                            0x0000000186dae1f4 -[NSManagedObjectContext save:] + 128

Please provide the environment you discovered this bug in

identus-edge-agent-sdk-swift 7.0.0

Anything else?

It would take a bit to isolate this into an example project, but I'm happy to show you the code over screen share in case it's something I'm doing wrong

Error Domain=NSCocoaErrorDomain Code=132001 "(null)" UserInfo={message=attempt to recursively call -save: on the context aborted, stack trace=(
0 CoreData 0x0000000186dae1f4 -[NSManagedObjectContext save:] + 128
1 FlightTix.debug.dylib 0x0000000108103604 $sSo22NSManagedObjectContextC5PlutoE13saveWithBlock5blockyyABKc_tKFyyXEfU_ + 336
2 FlightTix.debug.dylib 0x00000001080fd830 $sIg_Ieg_TR + 20
3 FlightTix.debug.dylib 0x00000001080fd854 $sIeg_IyB_TR + 24
4 CoreData 0x0000000186db77fc developerSubmittedBlockToNSManagedObjectContextPerform + 476
5 CoreData 0x0000000186db7598 -[NSManagedObjectContext performBlockAndWait:] + 256
6 FlightTix.debug.dylib 0x00000001081033a0 $sSo22NSManagedObjectContextC5PlutoE13saveWithBlock5blockyyABKc_tKF + 416
7 FlightTix.debug.dylib 0x0000000108101d38 $s5Pluto22WriteContextSubscriber33_196AB8F91B0AA4B62B3E4C9093010BD8LLC7performyyxF + 440
8 FlightTix.debug.dylib 0x0000000108101a74 $s5Pluto22WriteContextSubscriber33_196AB8F91B0AA4B62B3E4C9093010BD8LLC7requestyy7Combine11SubscribersO6DemandVF + 412
9 FlightTix.debug.dylib 0x0000000108102650 $s5Pluto22WriteContextSubscriber33_196AB8F91B0AA4B62B3E4C9093010BD8LLCyxq_G7Combine12SubscriptionAafGP7requestyyAF11SubscribersO6DemandVFTW + 20
10 Combine 0x00000001bd8404a0 $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLC12receiveInner12subscription_yAA12Subscription_p_SitF + 216
11 Combine 0x00000001bd8403bc $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLC4SideV7receive12subscriptionyAA12Subscription_p_tF + 20
12 FlightTix.debug.dylib 0x000000010810293c $s7Combine10PublishersO5PlutoE21WriteContextPublisherV7receive10subscriberyqd___t5InputQyd__RszAA10SubscriberRd__s5Error_p7FailureRtd__lF + 388
13 FlightTix.debug.dylib 0x0000000108102984 $s7Combine10PublishersO5PlutoE21WriteContextPublisherVy_xGAA0F0AdaHP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AMRtz5InputQyd__6OutputRtzlFTW + 40
14 Combine 0x00000001bd82702c $s7Combine12PublisherBoxC7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF + 36
15 Combine 0x00000001bd827234 $s7Combine12AnyPublisherV7receive10subscriberyqd___t5InputQyd__Rsz7FailureQyd__Rs_AA10SubscriberRd__lF + 36
16 Combine 0x00000001bd84132c $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLC7receiveyAA11SubscribersO6DemandV6OutputQy_F + 336
17 Combine 0x00000001bd84287c $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLCy_xq__qd__GAA10SubscriberA2aJP7receiveyAA11SubscribersO6DemandV5InputQzFTW + 20
18 Combine 0x00000001bd827670 $s7Combine10PublishersO3MapV5Inner33_5A6CD15A64659A6248DAF677D4BB6188LLV7receiveyAA11SubscribersO6DemandV6OutputQzF + 104
19 Combine 0x00000001bd7dbb2c $s7Combine14ReduceProducerC7receiveyAA11SubscribersO6DemandVq_F + 1440
20 Combine 0x00000001bd7dc324 $s7Combine14ReduceProducerCyxq_q0_q1_q2_GAA10SubscriberA2aEP7receiveyAA11SubscribersO6DemandV5InputQzFTW + 20
21 Combine 0x00000001bd827670 $s7Combine10PublishersO3MapV5Inner33_5A6CD15A64659A6248DAF677D4BB6188LLV7receiveyAA11SubscribersO6DemandV6OutputQzF + 104
22 FlightTix.debug.dylib 0x00000001080febd0 $s5Pluto24FetchedResultsSubscriber33_674D8215A765417DECF51A837DF0E94DLLC10controller_9didChange2at3for12newIndexPathySo09NSFetchedC10ControllerCySo20NSFetchRequestResult_pG_yp10Foundation0qR0VSgSo0scM4TypeVAQtF + 1276
23 FlightTix.debug.dylib 0x00000001080fee74 $s5Pluto24FetchedResultsSubscriber33_674D8215A765417DECF51A837DF0E94DLLC10controller_9didChange2at3for12newIndexPathySo09NSFetchedC10ControllerCySo20NSFetchRequestResult_pG_yp10Foundation0qR0VSgSo0scM4TypeVAQtFTo + 544
24 CoreData 0x0000000186e1b240 __82-[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:]_block_invoke + 5544
25 CoreData 0x0000000186db77fc developerSubmittedBlockToNSManagedObjectContextPerform + 476
26 CoreData 0x0000000186db7598 -[NSManagedObjectContext performBlockAndWait:] + 256
27 CoreData 0x0000000186e19c7c -[NSFetchedResultsController _core_managedObjectContextDidChange:] + 96
28 CoreFoundation 0x00000001803eb800 CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 140
29 CoreFoundation 0x00000001803eb724 ___CFXRegistrationPost_block_invoke + 84
30 CoreFoundation 0x00000001803eac14 _CFXRegistrationPost + 404
31 CoreFoundation 0x00000001803ea5f0 CFXNotificationPost + 688
32 Foundation 0x0000000180ed6820 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
33 CoreData 0x0000000186daa0d8 -[NSManagedObjectContext postObjectsDidChangeNotificationWithUserInfo:] + 320
34 CoreData 0x0000000186dbd6f8 -[NSManagedObjectContext createAndPostChangeNotification:deletions:updates:refreshes:deferrals:wasMerge:] + 1248
35 CoreData 0x0000000186dac14c -[NSManagedObjectContext processRecentChanges:] + 2840
36 CoreData 0x0000000186dae2c8 -[NSManagedObjectContext save:] + 340
37 FlightTix.debug.dylib 0x0000000108103604 $sSo22NSManagedObjectContextC5PlutoE13saveWithBlock5blockyyABKc_tKFyyXEfU
+ 336
38 FlightTix.debug.dylib 0x00000001080fd830 $sIg_Ieg_TR + 20
39 FlightTix.debug.dylib 0x00000001080fd854 $sIeg_IyB_TR + 24
40 CoreData 0x0000000186db77fc developerSubmittedBlockToNSManagedObjectContextPerform + 476
41 CoreData 0x0000000186db7598 -[NSManagedObjectContext performBlockAndWait:] + 256
42 FlightTix.debug.dylib 0x00000001081033a0 $sSo22NSManagedObjectContextC5PlutoE13saveWithBlock5blockyyABKc_tKF + 416
43 FlightTix.debug.dylib 0x0000000108101d38 $s5Pluto22WriteContextSubscriber33_196AB8F91B0AA4B62B3E4C9093010BD8LLC7performyyxF + 440
44 FlightTix.debug.dylib 0x0000000108101a74 $s5Pluto22WriteContextSubscriber33_196AB8F91B0AA4B62B3E4C9093010BD8LLC7requestyy7Combine11SubscribersO6DemandVF + 412
45 FlightTix.debug.dylib 0x0000000108102650 $s5Pluto22WriteContextSubscriber33_196AB8F91B0AA4B62B3E4C9093010BD8LLCyxq_G7Combine12SubscriptionAafGP7requestyyAF11SubscribersO6DemandVFTW + 20
46 Combine 0x00000001bd8404a0 $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLC12receiveInner12subscription_yAA12Subscription_p_SitF + 216
47 Combine 0x00000001bd8403bc $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLC4SideV7receive12subscriptionyAA12Subscription_p_tF + 20
48 FlightTix.debug.dylib 0x000000010810293c $s7Combine10PublishersO5PlutoE21WriteContextPublisherV7receive10subscriberyqd___t5InputQyd__RszAA10SubscriberRd__s5Error_p7FailureRtd__lF + 388
49 FlightTix.debug.dylib 0x0000000108102984 $s7Combine10PublishersO5PlutoE21WriteContextPublisherVy_xGAA0F0AdaHP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AMRtz5InputQyd__6OutputRtzlFTW + 40
50 Combine 0x00000001bd82702c $s7Combine12PublisherBoxC7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF + 36
51 Combine 0x00000001bd827234 $s7Combine12AnyPublisherV7receive10subscriberyqd___t5InputQyd__Rsz7FailureQyd__Rs_AA10SubscriberRd__lF + 36
52 Combine 0x00000001bd84132c $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLC7receiveyAA11SubscribersO6DemandV6OutputQy_F + 336
53 Combine 0x00000001bd84287c $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLCy_xq__qd__GAA10SubscriberA2aJP7receiveyAA11SubscribersO6DemandV5InputQzFTW + 20
54 Combine 0x00000001bd827670 $s7Combine10PublishersO3MapV5Inner33_5A6CD15A64659A6248DAF677D4BB6188LLV7receiveyAA11SubscribersO6DemandV6OutputQzF + 104
55 Combine 0x00000001bd7dbb2c $s7Combine14ReduceProducerC7receiveyAA11SubscribersO6DemandVq_F + 1440
56 Combine 0x00000001bd7dc324 $s7Combine14ReduceProducerCyxq_q0_q1_q2_GAA10SubscriberA2aEP7receiveyAA11SubscribersO6DemandV5InputQzFTW + 20
57 Combine 0x00000001bd827670 $s7Combine10PublishersO3MapV5Inner33_5A6CD15A64659A6248DAF677D4BB6188LLV7receiveyAA11SubscribersO6DemandV6OutputQzF + 104
58 FlightTix.debug.dylib 0x00000001080fd80c $s5Pluto24FetchedResultsSubscriber33_674D8215A765417DECF51A837DF0E94DLLC7requestyy7Combine11SubscribersO6DemandVFyyXEfU
+ 92
59 FlightTix.debug.dylib 0x00000001080fd830 $sIg_Ieg_TR + 20
60 FlightTix.debug.dylib 0x00000001080fd854 $sIeg_IyB_TR + 24
61 CoreData 0x0000000186db77fc developerSubmittedBlockToNSManagedObjectContextPerform + 476
62 libdispatch.dylib 0x00000001052b25d0 dispatch_client_callout + 16
63 libdispatch.dylib 0x00000001052c3b10 dispatch_sync_invoke_and_complete_recurse + 148
64 libdispatch.dylib 0x00000001052c3344 dispatch_sync_f_slow + 268
65 CoreData 0x0000000186db75c8 -[NSManagedObjectContext performBlockAndWait:] + 304
66 FlightTix.debug.dylib 0x00000001080fd5e4 $s5Pluto24FetchedResultsSubscriber33_674D8215A765417DECF51A837DF0E94DLLC7requestyy7Combine11SubscribersO6DemandVF + 1192
67 FlightTix.debug.dylib 0x00000001080ff238 $s5Pluto24FetchedResultsSubscriber33_674D8215A765417DECF51A837DF0E94DLLCyxG7Combine12SubscriptionAafGP7requestyyAF11SubscribersO6DemandVFTW + 20
68 Combine 0x00000001bd7db574 $s7Combine14ReduceProducerC7receive12subscriptionyAA12Subscription_p_tF + 444
69 Combine 0x00000001bd7dc304 $s7Combine14ReduceProducerCyxq_q0_q1_q2_GAA10SubscriberA2aEP7receive12subscriptionyAA12Subscription_p_tFTW + 20
70 FlightTix.debug.dylib 0x00000001080ff4b0 $s7Combine10PublishersO5PlutoE23FetchedResultsPublisherV7receive10subscriberyx_tAA10SubscriberRzs5Error_p7FailureRtzSaySo20NSFetchRequestResult_pG5InputRtzlF + 356
71 FlightTix.debug.dylib 0x00000001080ff554 $s7Combine10PublishersO5PlutoE23FetchedResultsPublisherVAA0F0AdaGP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__ALRtz5InputQyd__6OutputRtzlFTW + 28
72 Combine 0x00000001bd8274b4 $s7Combine10PublishersO3MapV7receive10subscriberyqd___t5InputQyd__Rs_AA10SubscriberRd__7FailureQyd__AKRtzlF + 268
73 Combine 0x00000001bd82702c $s7Combine12PublisherBoxC7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF + 36
74 Combine 0x00000001bd827234 $s7Combine12AnyPublisherV7receive10subscriberyqd___t5InputQyd__Rsz7FailureQyd__Rs_AA10SubscriberRd__lF + 36
75 Combine 0x00000001bd8477f0 $s7Combine10PublishersO5FirstV7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AIRtz5InputQyd__6OutputRtzlF + 288
76 Combine 0x00000001bd8274b4 $s7Combine10PublishersO3MapV7receive10subscriberyqd___t5InputQyd__Rs_AA10SubscriberRd__7FailureQyd__AKRtzlF + 268
77 Combine 0x00000001bd840178 $s7Combine10PublishersO7FlatMapV7receive10subscriberyqd___tAA10SubscriberRd__5InputQyd__6OutputRtz7FailureQyd__AMRt_lF + 304
78 Combine 0x00000001bd8274b4 $s7Combine10PublishersO3MapV7receive10subscriberyqd___t5InputQyd__Rs_AA10SubscriberRd__7FailureQyd__AKRtzlF + 268
79 Combine 0x00000001bd80e474 $s7Combine10PublishersO8MapErrorV7receive10subscriberyqd___t7FailureQyd__Rs_AA10SubscriberRd__5InputQyd__6OutputRtzlF + 268
80 Combine 0x00000001bd82702c $s7Combine12PublisherBoxC7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF + 36
81 Combine 0x00000001bd827234 $s7Combine12AnyPublisherV7receive10subscriberyqd___t5InputQyd__Rsz7FailureQyd__Rs_AA10SubscriberRd__lF + 36
82 Combine 0x00000001bd840178 $s7Combine10PublishersO7FlatMapV7receive10subscriberyqd___tAA10SubscriberRd__5InputQyd__6OutputRtz7FailureQyd__AMRt_lF + 304
83 Combine 0x00000001bd8477f0 $s7Combine10PublishersO5FirstV7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AIRtz5InputQyd__6OutputRtzlF + 288
84 Combine 0x00000001bd7e6054 $s7Combine22AsyncThrowingPublisherV8IteratorVyAEyx_GxcfC + 180
85 Combine 0x00000001bd7e65d8 $s7Combine14AsyncPublisherV04makeB8IteratorAC0E0Vyx_GyFTm + 104
86 FlightTix.debug.dylib 0x0000000107ef6b58 $s7Combine10PublishersO5FirstV4Cores5Error_p7FailureRtzrlE5await6OutputQzyYaKFTY0
+ 112
87 FlightTix.debug.dylib 0x000000010850f355 $s9EdgeAgent22ConnectionsManagerImplC11sendMessagey6Domain0G0VSgAGYaKFTQ1
+ 1
88 FlightTix.debug.dylib 0x000000010852f7b5 $s9EdgeAgent07DIDCommB0C11sendMessage7message6Domain0E0VSgAH_tYaKFTQ1
+ 1
89 FlightTix.debug.dylib 0x0000000107aa1c75 $s9FlightTix7IdentusC18startMessageStreamyyFy6Domain0E0VcfU0_yyYaKcfU_TQ5
+ 1
90 FlightTix.debug.dylib 0x0000000107aa5371 $s9FlightTix7IdentusC18startMessageStreamyyFy6Domain0E0VcfU0_yyYaKcfU_TATQ0
+ 1
91 libswift_Concurrency.dylib 0x00000002493a5829 _ZL23completeTaskWithClosurePN5swift12AsyncContextEPNS_10SwiftErrorE + 1
)}

@coveloper
Copy link
Author

Maybe the implementer needs to make sure messages only get processed in a serial queue? I think I'm spamming the processIssuedCredentialMessage method because I'm getting flooded with EVERY message (past and present) from Pluto every time I open my app and start receiving messages

@coveloper
Copy link
Author

Am I correct in locating this as the actual point where the NSManagedObjectContext does the save?

Image

If so, then performAndWait is correct and it's not the problem I thought it was. CD should be handling it correctly.

CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER would suggest that this operation is either being called from the wrong thread or there's a notification happening from the wrong thread.

@goncalo-frade-iohk goncalo-frade-iohk self-assigned this Jan 2, 2025
@goncalo-frade-iohk
Copy link
Contributor

Hey @coveloper , Happy New Year. Strange bug, can you replicate? I tried but I could not, and I think nothing really changed in the project Core Data Stack, I think the we can book a meet for the screen sharing ;)

@coveloper
Copy link
Author

I'm definitely seeing this all the time, but it might be just my naive way of handling the Message queue. I'm trying some work arounds now, but next week we could do a screen share session if I'm still having problems.

@coveloper
Copy link
Author

still hitting this crash consistently. would love to jump on a screen share with you this week sometime, I'm probably doing something wrong.

@goncalo-frade-iohk
Copy link
Contributor

Lets book it and go through it ;) we can talk on discord as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants