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

Crash in InMemoryNormalizedCache's clear #3489

Open
postmechanical opened this issue Dec 13, 2024 · 6 comments
Open

Crash in InMemoryNormalizedCache's clear #3489

postmechanical opened this issue Dec 13, 2024 · 6 comments
Assignees
Labels
bug Generally incorrect behavior needs investigation

Comments

@postmechanical
Copy link

Summary

SIGABRT crash due to Object 0x15ba38c80 of class _DictionaryStorage deallocated with non-zero retain count 2. This object's deinit, or something called from it, may have created a strong reference to self which outlived deinit, resulting in a dangling reference. when calling InMemoryNormalizedCache's clear method

Version

1.13.0

Steps to reproduce the behavior

Populate cache with some objects. Attempt to clear cache.

Logs

Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0xc1d4 __pthread_kill + 8
1  libsystem_pthread.dylib        0x7ef8 pthread_kill + 268
2  libsystem_c.dylib              0x77ad8 abort + 128
3  libswiftCore.dylib             0x3cc1a4 swift::fatalError(unsigned int, char const*, ...) + 134
4  libswiftCore.dylib             0x3cc1c4 swift::warningv(unsigned int, char const*, char*) + 30
5  libswiftCore.dylib             0x3d79ac swift_deallocPartialClassInstance + 306
6  libswiftCore.dylib             0x3d783c _swift_release_dealloc + 56
7  libswiftCore.dylib             0x3d8950 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 160
8  App                            0x1c0a634 destroy for Record + 36 (<compiler-generated>:36)
9  libswiftCore.dylib             0x3b56fc swift_arrayDestroy + 196
10 libswiftCore.dylib             0xd2fac _DictionaryStorage.deinit + 540
11 libswiftCore.dylib             0xd3040 _DictionaryStorage.__deallocating_deinit + 16
12 libswiftCore.dylib             0x3d783c _swift_release_dealloc + 56
13 libswiftCore.dylib             0x3d8950 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 160
14 libswiftCore.dylib             0xb5f00 Dictionary._Variant.removeAll(keepingCapacity:) + 100
15 App                            0x1c0b328 RecordSet.clear() + 27 (RecordSet.swift:27)
16 App                            0x1bed1c8 InMemoryNormalizedCache.clear() + 27 (InMemoryNormalizedCache.swift:27)
17 App                            0x165f688 ResponsiveInMemoryNormalizedCache.clear() + 36 (ResponsiveInMemoryNormalizedCache.swift:36)
18 App                            0x165f6d0 ResponsiveInMemoryNormalizedCache.didReceiveMemoryWarning() + 40 (ResponsiveInMemoryNormalizedCache.swift:40)
19 App                            0x165f728 @objc ResponsiveInMemoryNormalizedCache.didReceiveMemoryWarning() + 36 (<compiler-generated>:36)
20 CoreFoundation                 0x512f4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
21 CoreFoundation                 0x51210 ___CFXRegistrationPost_block_invoke + 88
22 CoreFoundation                 0x51158 _CFXRegistrationPost + 436
23 CoreFoundation                 0x4f70c _CFXNotificationPost + 728
24 Foundation                     0x2fea4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
25 UIKitCore                      0x1147b60 -[UIApplication _performMemoryWarning] + 128
26 UIKitCore                      0x1147cf4 -[UIApplication _receivedMemoryNotification] + 128
27 libdispatch.dylib              0x40d0 _dispatch_client_callout + 20
28 libdispatch.dylib              0x7580 _dispatch_continuation_pop + 596
29 libdispatch.dylib              0x1b53c _dispatch_source_latch_and_call + 420
30 libdispatch.dylib              0x1a104 _dispatch_source_invoke + 836
31 libdispatch.dylib              0x128f4 _dispatch_main_queue_drain + 744
32 libdispatch.dylib              0x125fc _dispatch_main_queue_callback_4CF + 44
33 CoreFoundation                 0x56204 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
34 CoreFoundation                 0x53440 __CFRunLoopRun + 1996
35 CoreFoundation                 0x52830 CFRunLoopRunSpecific + 588
36 GraphicsServices               0x11c4 GSEventRunModal + 164
37 UIKitCore                      0x3d2eb0 -[UIApplication _run] + 816
38 UIKitCore                      0x4815b4 UIApplicationMain + 340
39 App                            0x133ca0 main + 17 (AppDelegate.swift:17)
40 ???                            0x1b9356ec8 (Missing)

Anything else?

No response

@postmechanical postmechanical added bug Generally incorrect behavior needs investigation labels Dec 13, 2024
@calvincestari
Copy link
Member

@postmechanical - do you have any other detail about what was in progress at the time? Active queries, watchers, subscriptions, etc. Looks like the call to clear was in response to a memory warning on the device.

@postmechanical
Copy link
Author

postmechanical commented Dec 13, 2024

@calvincestari There were no active queries as the user was not actively using any features that hit our graph but I am not aware of what other watchers or subscriptions may have been active at the same time. The call to clear was in response to an app memory warning.

@calvincestari
Copy link
Member

A watcher was my first guess but I have not been able to replicate the crash with a rudimentary test. If you're able to reproduce this crash in a sample app that we can debug it'll certainly help to narrow down the cause.

@postmechanical
Copy link
Author

@calvincestari That's unlikely to happen anytime soon from our end.

@calvincestari
Copy link
Member

OK. We're entering a quiet period here over the holiday season, so once we're all back at it I'll take a deeper look into the code and try figure out what could be holding onto the reference.

@postmechanical
Copy link
Author

Understood. Much appreciated, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior needs investigation
Projects
None yet
Development

No branches or pull requests

2 participants