question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subscription addListener results in EXC_BAD_ACCESS crash

See original GitHub issue

Since the 2.13.0 release yesterday which I believe included the missing Realm.Sync.Subscription object being returned after subscribing to a results object. Calling the addlistener method provokes a crash on RN

Goals

Add a listener to a partial realm subscription object

Expected Results

Listener is added without issues.

Actual Results

The app crashes.

* thread #55, name = 'com.facebook.react.JavaScript', stop reason = EXC_BAD_ACCESS (code=1, address=0x3ed8)
    frame #0: 0x000000010aa3bb4f JavaScriptCore`JSC::JSLockHolder::JSLockHolder(JSC::ExecState*) + 15
    frame #1: 0x000000010a31bda1 JavaScriptCore`JSValueMakeNumber + 33
  * frame #2: 0x0000000106a6030f UgoApp`realm::js::Value<realm::jsc::Types>::from_number(ctx=0x000070000a78f320, number=1) at jsc_value.hpp:135
    frame #3: 0x0000000106aff5fb UgoApp`realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(this=0x000061400047f288)::'lambda'()::operator()() const at js_sync.hpp:673
    frame #4: 0x0000000106aff58d UgoApp`void std::__1::__invoke_void_return_wrapper<void>::__call<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&>(realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&&&) [inlined] decltype(__f=0x000061400047f288)::'lambda'()&>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&>(realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&&&) at type_traits:4323
    frame #5: 0x0000000106aff57c UgoApp`void std::__1::__invoke_void_return_wrapper<void>::__call<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(__args=0x000061400047f288)::'lambda'()&>(realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&&&) at __functional_base:349
    frame #6: 0x0000000106aff249 UgoApp`std::__1::__function::__func<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'(), std::__1::allocator<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()>, void ()>::operator(this=0x000061400047f280)() at functional:1562
    frame #7: 0x00000001062a6adb UgoApp`std::__1::function<void ()>::operator(this=0x000061400047f280)() const at functional:1921
    frame #8: 0x0000000106cc933d UgoApp`realm::partial_sync::Subscription::add_notification_callback(this=0x00006140002ae670, (null)=CollectionChangeSet @ 0x000070000a7902b0, (null)=(__ptr_ = 0x0000000000000000))>)::$_6::operator()(realm::CollectionChangeSet, std::exception_ptr) const at partial_sync.cpp:585
    frame #9: 0x0000000106cc8fe1 UgoApp`realm::CollectionChangeCallback::Impl<realm::partial_sync::Subscription::add_notification_callback(std::__1::function<void ()>)::$_6>::after(this=0x00006140002ae660, change=0x000070000a7903c0) at collection_notifications.hpp:157
    frame #10: 0x00000001069ff7ea UgoApp`realm::CollectionChangeCallback::after(this=0x000070000a7903b0, c=0x000070000a7903c0) at collection_notifications.hpp:122
    frame #11: 0x00000001069ff756 UgoApp`auto realm::_impl::CollectionNotifier::after_advance(this=0x000070000a790580, lock=0x000070000a7904d8, callback=0x00007fe7cf9020d0)::$_9::operator()<std::__1::unique_lock<std::__1::mutex>, realm::_impl::CollectionNotifier::Callback>(std::__1::unique_lock<std::__1::mutex>&, realm::_impl::CollectionNotifier::Callback&) const at collection_notifier.cpp:332
    frame #12: 0x00000001069f2d88 UgoApp`void realm::_impl::CollectionNotifier::for_each_callback<realm::_impl::CollectionNotifier::after_advance()::$_9>(this=0x00007fe7df60ba18, fn=0x000070000a790580)::$_9&&) at collection_notifier.cpp:378
    frame #13: 0x00000001069f2bd9 UgoApp`realm::_impl::CollectionNotifier::after_advance(this=0x00007fe7df60ba18) at collection_notifier.cpp:321
    frame #14: 0x00000001069f5618 UgoApp`realm::_impl::NotifierPackage::after_advance(this=0x000070000a7907a0) at collection_notifier.cpp:490
    frame #15: 0x0000000106ba46b4 UgoApp`realm::_impl::RealmCoordinator::advance_to_ready(this=0x00007fe7dc641b70, realm=0x00007fe7dc643eb0) at realm_coordinator.cpp:801
    frame #16: 0x0000000106c74f72 UgoApp`realm::Realm::notify(this=0x00007fe7dc643eb0) at shared_realm.cpp:801
    frame #17: 0x0000000106d6cebe UgoApp`realm::_impl::WeakRealmNotifier::Callback::operator(this=0x000060c000238460)() const at weak_realm_notifier.cpp:42
    frame #18: 0x0000000106d6df1c UgoApp`realm::util::EventLoopSignal<realm::_impl::WeakRealmNotifier::Callback>::EventLoopSignal(this=0x0000000106d6dee0, info=0x000060c000238460)::'lambda'(void*)::operator()(void*) const at event_loop_signal.hpp:37
    frame #19: 0x0000000106d6def8 UgoApp`realm::util::EventLoopSignal<realm::_impl::WeakRealmNotifier::Callback>::EventLoopSignal(info=0x000060c000238460)::'lambda'(void*)::__invoke(void*) at event_loop_signal.hpp:36
    frame #20: 0x000000010f953bb1 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame #21: 0x000000010f9384af CoreFoundation`__CFRunLoopDoSources0 + 271
    frame #22: 0x000000010f937a6f CoreFoundation`__CFRunLoopRun + 1263
    frame #23: 0x000000010f93730b CoreFoundation`CFRunLoopRunSpecific + 635
    frame #24: 0x0000000106230d6b UgoApp`::+[RCTCxxBridge runRunLoop](self=RCTCxxBridge, _cmd="runRunLoop") at RCTCxxBridge.mm:246
    frame #25: 0x000000010d4fa3b3 Foundation`__NSThread__start__ + 1221
    frame #26: 0x0000000110d16661 libsystem_pthread.dylib`_pthread_body + 340
    frame #27: 0x0000000110d1650d libsystem_pthread.dylib`_pthread_start + 377
    frame #28: 0x0000000110d15bf9 libsystem_pthread.dylib`thread_start + 13

Steps to Reproduce

Assign a listenr to a result as below…

Code Sample

const results = realm.objects('Job')
const subscription = results.subscribe()
subscription.addListener(() => {}) // crash here

Version of Realm and Tooling

  • Realm JS SDK Version: 2.13.0
  • Node or React Native: RN 0.55
  • Client OS & Version: IOS Simulator / osx
  • Which debugger for React Native: Chrome but it happens with or without debugging

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sambwestcommented, Sep 17, 2018

Apologies I think this is due to my updating. Gone in 2.15.3, thanks closing.

1reaction
knethcommented, Aug 23, 2018

@sambwest No, but it will be included in 2.15.0 which I will release today or tomorrow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

EXC_BAD_ACCESS crash error: Understanding and solving it
EXC_BAD_ACCESS is an exception raised as a result of accessing bad memory. We're constantly working with pointers to memory in Swift that link ......
Read more >
EXC_BAD_ACCESS Crash that we can't… - Apple Developer
Hello to everyone! We are getting this crash at 4% of our users and it occuries right at start of application, so the...
Read more >
Timeline - WebKit Trac
Fixed the crash by using variant of nextSkippingChildren which knows how ... between text input fields when listening with addEventListener
Read more >
Source - GitHub
Fix a race condition which could result in `operation cancelled` errors being ... Fixed flexible sync crash when updating subscriptions after token expiry....
Read more >
@expo/dev-server | Yarn - Package Manager
(#17402 by @wschurman); Fix addEventListener not returning a subscription on web. ... fixed EXC_BAD_ACCESS crashes on startup on iOS below 12.0 by @tsapeta ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found