Trying to create a subscription, getting a crash


#1

I probably have something configured wrong, but I can’t find the cause yet.

When I try to run the following line from my code:

subscription = events?.subscribe()

Causes the following line (431) from partial_sync.cpp to crash:

Subscription subscription(name, results.get_object_type(), realm);

Here is my stack trace. Anyone have any ideas? I’m not getting much/any actual reason for the crash.

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xe8)
  * frame #0: 0x000000010559823c Realm`realm::Table::SpecPtr::operator->(this=0x00000000000000e8) const at table.hpp:1019:20
    frame #1: 0x0000000105593f94 Realm`realm::Table::get_column_count(this=0x0000000000000000) const at table.hpp:1781:12
    frame #2: 0x00000001055eaa30 Realm`realm::ObjectSchema::ObjectSchema(this=0x000000016b756da8, group=0x000000010908ea10, name=(m_data = "__ResultSets", m_size = 12), index=18446744073709551615) at object_schema.cpp:84:27
    frame #3: 0x00000001055eb14c Realm`realm::ObjectSchema::ObjectSchema(this=0x000000016b756da8, group=0x000000010908ea10, name=(m_data = "__ResultSets", m_size = 12), index=18446744073709551615) at object_schema.cpp:75:92
    frame #4: 0x0000000105614604 Realm`realm::partial_sync::Subscription::Subscription(this=0x000000016b756da8, name="[Event] TRUEPREDICATE SORT(dateTime ASC)", object_type="Event", realm=std::__1::shared_ptr<realm::Realm>::element_type @ 0x0000000108140b78 strong=6 weak=5) at partial_sync.cpp:520:3
    frame #5: 0x0000000105612684 Realm`realm::partial_sync::Subscription::Subscription(this=0x000000016b756da8, name=<unavailable>, object_type=<unavailable>, realm=<unavailable>) at partial_sync.cpp:521:1
    frame #6: 0x000000010561200c Realm`realm::partial_sync::subscribe(results=0x000000010814d9e8, user_provided_name=Optional<std::__1::basic_string<char> > @ 0x000000016b756d88) at partial_sync.cpp:431:18
    frame #7: 0x000000010583619c Realm`::-[RLMSyncSubscription initWithName:results:realm:](self=0x000000010814dea0, _cmd="initWithName:results:realm:", name=0x0000000000000000, results=0x000000010814d9e8, realm=0x0000000283e18690) at RLMSyncSubscription.mm:51:25
    frame #8: 0x00000001058380ec Realm`::-[RLMResults(self=0x000000010814d9e0, _cmd="subscribe") subscribe]() at RLMSyncSubscription.mm:234:12
    frame #9: 0x0000000106ae3f6c RealmSwift`Results.subscribe(subscriptionName=nil, limit=nil, self=0x000000028170ab40) at Sync.swift:999:44
    frame #10: 0x00000001047712d0 Rover Challenge`EventsSetupTableViewController.viewDidLoad(self=0x000000010813bd80) at EventsSetupTableViewController.swift:108:32
    frame #11: 0x00000001047722ec Rover Challenge`@objc EventsSetupTableViewController.viewDidLoad() at <compiler-generated>:0
    frame #12: 0x000000021a0f1890 UIKitCore`-[UIViewController loadViewIfRequired] + 1000
    frame #13: 0x000000021a0f1cc0 UIKitCore`-[UIViewController view] + 28
    frame #14: 0x000000021a84cd84 UIKitCore`__67-[UIStoryboardEmbedSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 176
    frame #15: 0x000000021a84ef1c UIKitCore`-[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 292
    frame #16: 0x000000021a84edc8 UIKitCore`-[UIStoryboardSegueTemplate _perform:] + 92
    frame #17: 0x000000021a84f094 UIKitCore`-[UIStoryboardSegueTemplate perform:] + 160
    frame #18: 0x000000021a0f16f0 UIKitCore`-[UIViewController loadViewIfRequired] + 584
    frame #19: 0x000000021a0f1cc0 UIKitCore`-[UIViewController view] + 28
    frame #20: 0x000000021a0325ec UIKitCore`-[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 740
    frame #21: 0x000000021a0319e0 UIKitCore`-[UITabBarController transitionFromViewController:toViewController:] + 68
    frame #22: 0x000000021a02e0c4 UIKitCore`-[UITabBarController _setSelectedViewController:] + 400
    frame #23: 0x000000021a02de94 UIKitCore`-[UITabBarController setSelectedViewController:] + 112
    frame #24: 0x000000021ab53818 UIKitCore`+[UIView(Animation) performWithoutAnimation:] + 104
    frame #25: 0x000000021a02876c UIKitCore`-[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 464
    frame #26: 0x000000021a0295f8 UIKitCore`-[UITabBarController viewWillAppear:] + 208
    frame #27: 0x000000021a0f6f70 UIKitCore`-[UIViewController _setViewAppearState:isAnimating:] + 584
    frame #28: 0x000000021a0f7654 UIKitCore`-[UIViewController __viewWillAppear:] + 140
    frame #29: 0x000000021a04a55c UIKitCore`-[UINavigationController _startCustomTransition:] + 1312
    frame #30: 0x000000021a05ef6c UIKitCore`-[UINavigationController _startDeferredTransitionIfNeeded:] + 716
    frame #31: 0x000000021a060440 UIKitCore`-[UINavigationController __viewWillLayoutSubviews] + 164
    frame #32: 0x000000021a042630 UIKitCore`-[UILayoutContainerView layoutSubviews] + 224
    frame #33: 0x000000021ab6177c UIKitCore`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1380
    frame #34: 0x00000001f200db7c QuartzCore`-[CALayer layoutSublayers] + 184
    frame #35: 0x00000001f2012b34 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 324
    frame #36: 0x00000001f1f71598 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 340
    frame #37: 0x00000001f1f9fec8 QuartzCore`CA::Transaction::commit() + 608
    frame #38: 0x00000001f1fa0d30 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
    frame #39: 0x00000001ed9a16bc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
    frame #40: 0x00000001ed99c350 CoreFoundation`__CFRunLoopDoObservers + 412
    frame #41: 0x00000001ed99c8f0 CoreFoundation`__CFRunLoopRun + 1264
    frame #42: 0x00000001ed99c0e0 CoreFoundation`CFRunLoopRunSpecific + 436
    frame #43: 0x00000001efc15584 GraphicsServices`GSEventRunModal + 100
    frame #44: 0x000000021a6b8c00 UIKitCore`UIApplicationMain + 212
    frame #45: 0x0000000104748a74 Rover Challenge`main at AppDelegate.swift:22:7
    frame #46: 0x00000001ed45abb4 libdyld.dylib`start + 4

#2

@perlguy that’s crashing when dereferencing a null pointer when trying to access the __ResultsSets table, which indicates that you’ve somehow opened a Realm in query-based mode without it having a __ResultSets table

How did you create this realm? Try creating a new realm URL and run the same code and see if that works.