realm-core: Crash in TableRecycler::~TableRecycler when Catalyst app is terminated
Goals
We use Realm in our Catalyst app and see a crasher in TableRecycler::~TableRecycler
when the application is terminated.
So far, we haven’t been able to reproduce the issue locally but we see about 500 crash reports per day.
From looking at the Realm code, it looks like the same table instance is somehow added to g_table_recycler_1
and/or g_table_recycler_2
more than once. When the app gets terminated and the recyclers are deallocated, it will try to deallocate the same table multiple times triggering the crash we’re seeing. This is just a guess from our side though.
We have around 150 tables which means we would trigger the table recycling code in Group::create_table_accessor(size_t table_ndx)
(g_table_recycling_delay
).
If there is anything I can help with please let me know.
Expected Results
App terminates successfully
Actual Results
C++ Exception
NSt3__112system_errorE
libsystem_malloc 0x7fff202cdd01 tiny_free_list_add_ptr
libsystem_malloc 0x7fff202cd7a9 tiny_free_no_lock
libsystem_malloc 0x7fff202cd1f8 free_tiny
Realm 0x00010dbe7752 realm::Table::~Table
Realm 0x00010db07cc8 realm::Group::TableRecycler::~TableRecycler
libsystem_c 0x7fff203cfca6 __cxa_finalize_ranges
libsystem_c 0x7fff203cff91 exit
AppKit 0x7fff230612f5 -[NSApplication terminate:]
Foundation 0x7fff21346ada __NSFireDelayedPerform
CoreFoundation 0x7fff205b390c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
CoreFoundation 0x7fff205b33e7 __CFRunLoopDoTimer
CoreFoundation 0x7fff205b2f41 __CFRunLoopDoTimers
CoreFoundation 0x7fff2059957e __CFRunLoopRun
CoreFoundation 0x7fff205986cd CFRunLoopRunSpecific
HIToolbox 0x7fff2882062f RunCurrentEventLoopInMode
HIToolbox 0x7fff28820281 ReceiveNextEventCommon
HIToolbox 0x7fff2882014e _BlockUntilNextEventMatchingListInModeWithFilter
AppKit 0x7fff22db89b0 _DPSNextEvent
AppKit 0x7fff22db7176 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
AppKit 0x7fff22da9689 -[NSApplication run]
AppKit 0x7fff22d7d96e NSApplicationMain
AppKit 0x7fff230743ba _NSApplicationMainWithInfoDictionary
UIKitMacHelper 0x7fff341defa9 UINSApplicationMain
UIKitCore 0x7fff44e6edaf UIApplicationMain
Jira 0x00010a9e458c main (main.swift)
libdyld 0x7fff204bd620 start
Steps for others to Reproduce
Unfortunately, we don’t have any repro steps yet.
Code Sample
N/A
Version of Realm and Tooling
Realm framework version: 10.6.0
Realm Object Server version: N/A
Xcode version: 12.4
iOS/OSX version: Crash reports range from 10.5.7 - 11.2.3
Dependency manager + version: Carthage 0.37.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (11 by maintainers)
@ianpward @finnschiermer We have rolled out a new version of our app and we have not seen a single Realm crash so far. Thanks again for your help!
@simonboots We’ve identified a bug related to management of Table::m_index_accessors, so thanks a lot for your input. It is unclear if that bug is the root cause of the problem in this issue, though. Investigation continues.
@simonboots We expect the fix to be part of next release. Since we can’t reproduce the problem, it’d be awesome if you will try it out and report back if it fixes the problem or not.
As an opening point, let me add that there is no risk of data loss in this situation. We have not seen this problem internally, even though we have tests which should catch such an issue. but it’s obviously annoying, and it may point to a deeper problem. We’ll investigate.
@simonboots The core team will look into this. I’ve transferred the issue to their repo. We’ll continue there. 👍