realm-js: 6.0.3 iOS native crash - Attempted to dereference null pointer.

Goals

Regular offline use (no syncing)

Expected Results

No crashes

Actual Results

Random crash due to garbage / null reference.

The following crash was reported from Realm code.

EXC_BAD_ACCESS Attempted to dereference null pointer. 
    Tenant Move-In realm::jsc::ObjectWrap<realm::js::SessionClass<realm::jsc::Types> >::set_readonly_property(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const*, OpaqueJSValue const**)
    Tenant Move-In bool realm::js::wrap<&realm::js::ListClass<realm::jsc::Types>::set_index>(OpaqueJSContext const*, OpaqueJSValue*, unsigned int, OpaqueJSValue const*, OpaqueJSValue const**)
    Tenant Move-In bool realm::js::wrap<&realm::js::ListClass<realm::jsc::Types>::set_index>(OpaqueJSContext const*, OpaqueJSValue*, unsigned int, OpaqueJSValue const*, OpaqueJSValue const**)
    Tenant Move-In OpaqueJSValue const* realm::js::wrap<&realm::js::RealmClass<realm::jsc::Types>::get_is_partial_realm>(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)
    Tenant Move-In OpaqueJSValue const* realm::js::wrap<&realm::js::RealmClass<realm::jsc::Types>::object_for_primary_key>(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**)
    Frameworks/JavaScriptCore.framework/JavaScriptCore long long JSC::APICallbackFunction::call<JSC::JSCallbackFunction>(JSC::JSGlobalObject*, JSC::CallFrame*)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _vmEntryToJavaScript
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _JSObjectCallAsFunction
    Tenant Move-In OpaqueJSValue const* realm::js::wrap<&realm::js::RealmClass<realm::jsc::Types>::get_is_partial_realm>(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)
    Tenant Move-In OpaqueJSValue const* realm::js::wrap<&realm::js::RealmClass<realm::jsc::Types>::write>(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**)
    Frameworks/JavaScriptCore.framework/JavaScriptCore long long JSC::APICallbackFunction::call<JSC::JSCallbackFunction>(JSC::JSGlobalObject*, JSC::CallFrame*)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _vmEntryToJavaScript
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::boundThisNoArgsFunctionCall(JSC::JSGlobalObject*, JSC::CallFrame*)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _vmEntryToNative
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _JSObjectCallAsFunction
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRunLoopDoBlocks
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRunLoopRun
    Frameworks/CoreFoundation.framework/CoreFoundation _CFRunLoopRunSpecific
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Frameworks/Foundation.framework/Foundation ___NSThread__start__
    /usr/lib/system/libsystem_pthread.dylib __pthread_start

While I understand this is probably extremely hard to debug/reproduce in a controlled environment, it would be great for Realm to attempt to handle null pointer exceptions in a way that won’t crash the whole app, but rather cause a query error or something. This is probably one out of 10 different realm-related native crashes that are reported daily from our crash reporting tool.

Similar crashes: https://github.com/realm/realm-js/issues/3111 https://github.com/realm/realm-js/issues/2853 https://github.com/realm/realm-js/issues/2828 https://github.com/realm/realm-js/issues/2713

Steps to Reproduce

Regular realm usage without any sync/online features.

Code Sample

Regular offline use, no special code required.

Version of Realm and Tooling

  • Realm JS SDK Version: ? 6.0.3
  • Node or React Native: ? React Native 0.61.5
  • Client OS & Version: ? iOS 13.6 / iPhone 8
  • Which debugger for React Native: None - production build

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 70 (21 by maintainers)

Most upvoted comments

Just adding to this thread, that I’ve started to see this in a client’s React Native app since updating to Realm JS 10.0.1, alongside react-native @ 0.63.3.

The crash logs basically match the ones above, and Sentry & Firebase (along with internal logs) are reporting that they’re always occurring whilst the app isn’t active. Happy to help with testing fixes, let me know if that’d be useful!

@CoSNaYe Since an upgrade of Realm Core is involved, I have asked @finnschiermer and @jedelbo to take a look.

@kneth I’ve just got this kind of crash during debugging. The crash seemed to happen right after “swiping out” the app (killing it) and while realm was doing something. Here’s a capture of the debugger stack trace, hopefully it helps a bit.

I created an app that can reproduce this latest reported crash: https://github.com/kraenhansen/realm-js-issue-3112 … perhaps that will provide us a hint to eventually solve some of the shutdown related crashes.

@steffenagger I have updated to RN 0.62 a while ago and some of these crashes still happen (like the one from the most recent stack trace I’ve uploaded).

Another one popped out today… May be related:

EXC_BAD_ACCESS Attempted to dereference garbage pointer 0x10. 
    Frameworks/JavaScriptCore.framework/JavaScriptCore bool JSC::symbolTableGet<JSC::JSGlobalObject>(JSC::JSGlobalObject*, JSC::PropertyName, JSC::PropertySlot&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::JSObject::get(JSC::JSGlobalObject*, JSC::PropertyName) const
    Frameworks/JavaScriptCore.framework/JavaScriptCore _JSObjectGetProperty
    zinspector3 void std::__1::__call_once_proxy<std::__1::tuple<realm::SyncManager& realm::js::syncManagerShared<realm::jsc::Types>(realm::jsc::Types::Context&)::{lambda()#1}&&> >(void*)
    zinspector3 void std::__1::__call_once_proxy<std::__1::tuple<realm::SyncManager& realm::js::syncManagerShared<realm::jsc::Types>(realm::jsc::Types::Context&)::{lambda()#1}&&> >(void*)
    zinspector3 bool realm::js::wrap<&realm::js::ListClass<realm::jsc::Types>::set_index>(OpaqueJSContext const*, OpaqueJSValue*, unsigned int, OpaqueJSValue const*, OpaqueJSValue const**)
    zinspector3 OpaqueJSValue const* realm::js::wrap<&realm::js::ResultsClass<realm::jsc::Types>::get_index>(OpaqueJSContext const*, OpaqueJSValue*, unsigned int, OpaqueJSValue const**)
    zinspector3 OpaqueJSValue const* realm::js::wrap<&realm::js::ResultsClass<realm::jsc::Types>::sorted>(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**)
    Frameworks/JavaScriptCore.framework/JavaScriptCore long long JSC::APICallbackFunction::call<JSC::JSCallbackFunction>(JSC::JSGlobalObject*, JSC::CallFrame*)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _vmEntryToJavaScript
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::boundThisNoArgsFunctionCall(JSC::JSGlobalObject*, JSC::CallFrame*)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _vmEntryToNative
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _JSObjectCallAsFunction
    zinspector3 facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    zinspector3 facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    zinspector3 facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    zinspector3 facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    zinspector3 facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    zinspector3 facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    zinspector3 facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    zinspector3 facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRunLoopDoBlocks
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRunLoopRun
    Frameworks/CoreFoundation.framework/CoreFoundation _CFRunLoopRunSpecific
    zinspector3 facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Frameworks/Foundation.framework/Foundation ___NSThread__start__
    /usr/lib/system/libsystem_pthread.dylib __pthread_start

We have been getting a significant amount of crashes ever since 5.0.3 to 6.x migration from Realm.

@kneth I’ve opened a new issue with as much detail as I could gather, including multiple stack traces (https://github.com/realm/realm-js/issues/4473)

One thing I’ve discovered when building Objective-C/Swift code for other native modules, memory exceptions will not be handled by any try/catch block, they will always crash the app, no matter what, so proper cleanup/access of pointers is required.

@kneth it’s not really an app hang, but rather a crash right after the app is being terminated. Somewhere in the code trying to use resources that have been already released.

@kneth I’ve just got this kind of crash during debugging. The crash seemed to happen right after “swiping out” the app (killing it) and while realm was doing something. Here’s a capture of the debugger stack trace, hopefully it helps a bit.

Screen Shot 2021-02-23 at 23 47 17

@bmunkholm about the stack trace I’ve just posted above. After further research, looks like this crash is quite new and wasn’t seen in any previous versions (it is either realm 10.1.3 or 10.1.4)

@enigmablue @cristianoccazinsp @ryanbourneuk @feliperoan @CoSNaYe Have any of you tried this on the newer Realm-JS v10? We have made some changes to the way open realms are cached in v10, and the stack traces indicate that this may be related.

This is a new one, also on 6.0.3:

EXC_BAD_ACCESS Attempted to dereference null pointer. 
    Tenant Move-In realm::Obj& realm::Obj::set<realm::Timestamp>(realm::ColKey, realm::Timestamp, bool)
    Tenant Move-In bool realm::Array::find<realm::Less, (realm::Action)0, 64ul>(long long, unsigned long, unsigned long, unsigned long, realm::QueryState<long long>*) const
    Tenant Move-In realm::Obj& realm::Obj::set<realm::Timestamp>(realm::ColKey, realm::Timestamp, bool)
    Tenant Move-In realm::Obj& realm::Obj::set<realm::Timestamp>(realm::ColKey, realm::Timestamp, bool)
    Tenant Move-In bool realm::js::wrap<&realm::js::ListClass<realm::jsc::Types>::set_index>(OpaqueJSContext const*, OpaqueJSValue*, unsigned int, OpaqueJSValue const*, OpaqueJSValue const**)
    Tenant Move-In OpaqueJSValue const* realm::js::wrap<&realm::js::RealmObjectClass<realm::jsc::Types>::get_realm>(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)
    Tenant Move-In OpaqueJSValue const* realm::js::wrap<&realm::js::RealmObjectClass<realm::jsc::Types>::get_property>(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::JSCallbackObject<JSC::JSNonFinalObject>::call(JSC::JSGlobalObject*, JSC::CallFrame*)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _vmEntryToNative
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::callGetter(JSC::JSGlobalObject*, JSC::JSValue, JSC::JSValue)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_slow_path_get_by_id
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _llint_entry
    Frameworks/JavaScriptCore.framework/JavaScriptCore _vmEntryToJavaScript
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::boundThisNoArgsFunctionCall(JSC::JSGlobalObject*, JSC::CallFrame*)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _vmEntryToNative
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore JSC::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
    Frameworks/JavaScriptCore.framework/JavaScriptCore _JSObjectCallAsFunction
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRunLoopDoBlocks
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRunLoopRun
    Frameworks/CoreFoundation.framework/CoreFoundation _CFRunLoopRunSpecific
    Tenant Move-In facebook::react::JSIExecutor::defaultTimeoutInvoker(std::__1::function<void ()> const&, std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > ()>)
    Frameworks/Foundation.framework/Foundation ___NSThread__start__
    /usr/lib/system/libsystem_pthread.dylib __pthread_start

Perhaps this is caused by having a single global realm instance across the app instead of creating a new one before each query?