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

Strange log message: "N5realm10LogicErrorE: Bad version number" #4422

Closed
adomanico opened this issue Dec 7, 2016 · 25 comments
Closed

Strange log message: "N5realm10LogicErrorE: Bad version number" #4422

adomanico opened this issue Dec 7, 2016 · 25 comments

Comments

@adomanico
Copy link
Contributor

Seeing the following in our logs randomly

uncaught exception in notifier thread: N5realm10LogicErrorE: Bad version number

Unfortunately, don't have any specific steps to reproduce. Doesn't seem to be causing any issues but thought I would let you guys know

Realm version: 2.1.1

Xcode version: 8.2 beta 2

iOS/OSX version: 10.1

Dependency manager + version: Carthage 18.1

@jpsim
Copy link
Contributor

jpsim commented Dec 7, 2016

Thanks for reporting this. Could you share a complete stack trace the next time this happens?

We won't be able to do anything until we have more steps.

@adomanico
Copy link
Contributor Author

There is actually no crash just randomly seeing it in our logs

@jpsim
Copy link
Contributor

jpsim commented Dec 7, 2016

Hmm, since that's an exception being thrown, it should crash your app, unless you're catching exceptions, which isn't something I'd advise...

Unless I'm missing more context here. I don't think we ever translate this specific exception to an NSError, but it's hard to say without a more complete stack trace.

@sadiq81
Copy link

sadiq81 commented Dec 9, 2016

I have just experience the same thing after update carthage dependencies.

I opens the debugger in the following file "group_shared.hpp" at line 911 in method

I am saving an object which i have in a Result where i listen to changesets

inline void SharedGroup::advance_read(O* observer, VersionID version_id)
{
    if (m_transact_stage != transact_Reading)
        throw LogicError(LogicError::wrong_transact_state); <---

    // It is an error if the new version precedes the currently bound one.
    if (version_id.version < m_read_lock.m_version)
        throw LogicError(LogicError::bad_version);

    _impl::History* hist = get_history(); // Throws
    if (!hist)
        throw LogicError(LogicError::no_history);

    do_advance_read(observer, version_id, *hist); // Throws
}

Here is my cart file

#carthage update --platform iOS --no-use-binaries

github "SnapKit/SnapKit" "3.0.2"
github "realm/realm-cocoa"
github "ReactiveX/RxSwift"
github "vikmeup/SCLAlertView-Swift" "0.7.0"
github "Moya/Moya" "8.0.0-beta.3"
github "lyft/mapper"
github "SVProgressHUD/SVProgressHUD"
github "onevcat/Kingfisher" ~> 3.0

when updating carthage dependencies i also get this strange warning

ld: warning: direct access in function 'realm::SharedGroup::SharedGroup(realm::Replication&, realm::SharedGroupOptions)' from file '/Users/privat/Library/Developer/Xcode/DerivedData/Realm-fkmawtyyvoakkecjyipnprmiudip/Build/Intermediates/Realm.build/Release-iphoneos/Realm.build/Objects-normal/armv7/shared_realm.o' to global weak symbol 'realm::util::InterprocessMutex::initialize_statics()' from file 'core/librealm-ios.a(client_file_access_cache-iphoneos.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

@rgdev
Copy link

rgdev commented Dec 12, 2016

I'm having the same issue when launching my app.

uncaught exception in notifier thread: N5realm10LogicErrorE: Bad version number

  • Realm 2.1.1 (RealmSwift/cocoapods)
  • iOS 10.1
  • XCode 8.1

No crash and everything is working fine. It seems to only appear once in the log.

@adomanico adomanico reopened this Dec 12, 2016
@adomanico
Copy link
Contributor Author

Sounds like I'm not the only one

@jpsim
Copy link
Contributor

jpsim commented Dec 12, 2016

Can anyone here actually share steps to reproduce? Seems like this might happen if you're calling Realm.refresh() from within a write transaction. Are any of you doing that @adomanico @rgdev @sadiq81 ? If you set a symbolic breakpoint on exceptions in Xcode, can you identify where in your code this exception is being thrown (and presumably caught)? A stack trace would be useful here too.

@adomanico
Copy link
Contributor Author

Not calling realm.refresh() anywhere in our project.

Ill set a symbolic break point and see if I can catch it

@tbaranes
Copy link

tbaranes commented Dec 14, 2016

Here the exception stack using All exceptions breakpoint:

(lldb) bt
Realm was compiled with optimization - stepping may behave oddly; variables may not be available.
* thread #22: tid = 0x173e57, 0x00000001870ceefc libc++abi.dylib`__cxa_throw, name = 'RLMRealm notification listener', stop reason = breakpoint 1.1
    frame #0: 0x00000001870ceefc libc++abi.dylib`__cxa_throw
  * frame #1: 0x0000000101c4396c Realm`void realm::LangBindHelper::advance_read<(anonymous namespace)::TransactLogValidator>(realm::SharedGroup&, (anonymous namespace)::TransactLogValidator&&, realm::VersionID) [inlined] void realm::SharedGroup::advance_read<(anonymous namespace)::TransactLogValidator>(this=<unavailable>)::TransactLogValidator*, realm::VersionID) + 236 at group_shared.hpp:911 [opt]
    frame #2: 0x0000000101c438a0 Realm`void realm::LangBindHelper::advance_read<(anonymous namespace)::TransactLogValidator>(realm::SharedGroup&, (anonymous namespace)::TransactLogValidator&&, realm::VersionID) [inlined] void realm::_impl::SharedGroupFriend::advance_read<(anonymous namespace)::TransactLogValidator>(sg=<unavailable>)::TransactLogValidator*, realm::VersionID) at group_shared.hpp:1086 [opt]
    frame #3: 0x0000000101c438a0 Realm`void realm::LangBindHelper::advance_read<(anonymous namespace)::TransactLogValidator>(sg=<unavailable>, observer=<unavailable>, version=<unavailable>)::TransactLogValidator&&, realm::VersionID) + 32 at lang_bind_helper.hpp:335 [opt]
    frame #4: 0x0000000101c3ef58 Realm`realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID) [inlined] auto realm::_impl::transaction::advance(args=<unavailable>)::$_0::operator()<(anonymous namespace)::TransactLogValidator>((anonymous namespace)::TransactLogValidator&&) const + 292 at transact_log_handler.cpp:823 [opt]
    frame #5: 0x0000000101c3ef44 Realm`realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID) [inlined] (anonymous namespace)::TransactLogObserver::TransactLogObserver<realm::_impl::transaction::advance(this=0x000000016e6fea40, context=0x0000000000000000, sg=0x0000000105156600, notifiers=<unavailable>)::$_0>(realm::BindingContext*, realm::SharedGroup&, realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID)::$_0&&, realm::util::Optional<realm::SchemaMode>, realm::_impl::NotifierPackage&) + 196 at transact_log_handler.cpp:274 [opt]
    frame #6: 0x0000000101c3ee80 Realm`realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID) [inlined] (anonymous namespace)::TransactLogObserver::TransactLogObserver<realm::_impl::transaction::advance(context=0x0000000000000000, sg=0x0000000105156600, notifiers=<unavailable>)::$_0>(realm::BindingContext*, realm::SharedGroup&, realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID)::$_0&&, realm::util::Optional<realm::SchemaMode>, realm::_impl::NotifierPackage&) at transact_log_handler.cpp:262 [opt]
    frame #7: 0x0000000101c3ee80 Realm`realm::_impl::transaction::advance(sg=0x0000000105156600, context=0x0000000000000000, schema_mode=<unavailable>, version=<unavailable>) + 76 at transact_log_handler.cpp:822 [opt]
    frame #8: 0x0000000101b86f04 Realm`realm::_impl::RealmCoordinator::run_async_notifiers(this=<unavailable>) + 1136 at realm_coordinator.cpp:587 [opt]
    frame #9: 0x0000000101b86a40 Realm`realm::_impl::RealmCoordinator::on_change(this=0x0000000104567eb8) + 24 at realm_coordinator.cpp:410 [opt]
    frame #10: 0x0000000101b6f9e4 Realm`realm::_impl::ExternalCommitHelper::listen(this=<unavailable>) + 172 at external_commit_helper.cpp:214 [opt]
    frame #11: 0x0000000101b70ac0 Realm`std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator()() [inlined] realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0::operator()() const + 28 at external_commit_helper.cpp:159 [opt]
    frame #12: 0x0000000101b70abc Realm`std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator()() [inlined] std::__1::__invoke<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(decltype(std::__1::forward<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(fp)(std::__1::forward<>(fp0))), realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0&&) + 4 at __functional_base:416 [opt]
    frame #13: 0x0000000101b70ab8 Realm`std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator()() [inlined] _ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE(this=<unavailable>) at future:2348 [opt]
    frame #14: 0x0000000101b70ab8 Realm`std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator(this=<unavailable>)() + 20 at future:2341 [opt]
    frame #15: 0x0000000101b70a48 Realm`std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::__execute(this=0x000000017012a500) + 28 at future:1031 [opt]
    frame #16: 0x0000000101b70c10 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) [inlined] std::__1::__invoke<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*, void>(decltype(*(std::__1::forward<std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*>(fp0)).*fp(std::__1::forward<>(fp1))), void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*&&)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*&&) + 84 at __functional_base:383 [opt]
    frame #17: 0x0000000101b70bf4 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) [inlined] _ZNSt3__116__thread_executeIMNS_19__async_assoc_stateIvNS_12__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS4_16RealmCoordinatorEE3$_0JEEEEEFvvEJPSA_EJLm1EEEEvRNS_5tupleIJT_DpT0_EEENS_15__tuple_indicesIJXspT1_EEEE at thread:347 [opt]
    frame #18: 0x0000000101b70bf4 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(__vp=0x0000000170037a40) + 56 at thread:357 [opt]
    frame #19: 0x000000018773c850 libsystem_pthread.dylib`_pthread_body + 240
    frame #20: 0x000000018773c760 libsystem_pthread.dylib`_pthread_start + 284
    frame #21: 0x0000000187739dac libsystem_pthread.dylib`thread_start + 4

As said in #4428, we don't have the steps to reproduce it, but once that exception has been fired the interface will freeze (dead lock in the writeTransaction)

@rgdev
Copy link

rgdev commented Dec 14, 2016

Managed to get a stack in Simulator (iOS 10.2 / Realm(Swift) 2.1.1 / XCode 8.2).
The app does some writing and reading from Realm without any issues (before and after exception).

I can't find any pattern that would triggers the exception.
The exception doesn't crash or freeze the app nor prevent using the Realm normally.

* thread #13: tid = 0x565deb, 0x0000000114aeb867 libc++abi.dylib`__cxa_throw, name = 'RLMRealm notification listener', stop reason = breakpoint 1.2
    frame #0: 0x0000000114aeb867 libc++abi.dylib`__cxa_throw
  * frame #1: 0x000000011091601c Realm`void realm::SharedGroup::advance_read<(anonymous namespace)::TransactLogValidator>(this=0x00007ff48b8ba000, observer=0x0000700009caea88, version_id=(version = 9, index = 8))::TransactLogValidator*, realm::VersionID) + 220 at group_shared.hpp:915
    frame #2: 0x0000000110915f2b Realm`void realm::_impl::SharedGroupFriend::advance_read<(anonymous namespace)::TransactLogValidator>(sg=0x00007ff48b8ba000, obs=0x0000700009caea88, ver=(version = 9, index = 8))::TransactLogValidator*, realm::VersionID) + 59 at group_shared.hpp:1086
    frame #3: 0x0000000110915edb Realm`void realm::LangBindHelper::advance_read<(anonymous namespace)::TransactLogValidator>(sg=0x00007ff48b8ba000, observer=0x0000700009caea88, version=(version = 9, index = 8))::TransactLogValidator&&, realm::VersionID) + 59 at lang_bind_helper.hpp:335
    frame #4: 0x0000000110915865 Realm`auto realm::_impl::transaction::advance(this=0x0000700009caee60, args=0x0000700009caea88)::$_0::operator()<(anonymous namespace)::TransactLogValidator>((anonymous namespace)::TransactLogValidator&&) const + 69 at transact_log_handler.cpp:823
    frame #5: 0x000000011091517e Realm`(anonymous namespace)::TransactLogObserver::TransactLogObserver<realm::_impl::transaction::advance(this=0x0000700009caee70, context=0x0000000000000000, sg=0x00007ff48b8ba000, func=0x0000700009caee60, schema_mode=Optional<realm::SchemaMode> @ 0x0000700009caee58, notifiers=0x0000700009caeee8)::$_0>(realm::BindingContext*, realm::SharedGroup&, realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID)::$_0&&, realm::util::Optional<realm::SchemaMode>, realm::_impl::NotifierPackage&) + 1022 at transact_log_handler.cpp:274
    frame #6: 0x000000011090ece5 Realm`(anonymous namespace)::TransactLogObserver::TransactLogObserver<realm::_impl::transaction::advance(this=0x0000700009caee70, context=0x0000000000000000, sg=0x00007ff48b8ba000, func=0x0000700009caee60, schema_mode=<unavailable>, notifiers=0x0000700009caeee8)::$_0>(realm::BindingContext*, realm::SharedGroup&, realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID)::$_0&&, realm::util::Optional<realm::SchemaMode>, realm::_impl::NotifierPackage&) + 53 at transact_log_handler.cpp:262
    frame #7: 0x000000011090ec35 Realm`realm::_impl::transaction::advance(sg=0x00007ff48b8ba000, context=0x0000000000000000, schema_mode=Automatic, version=(version = 9, index = 8)) + 149 at transact_log_handler.cpp:822
    frame #8: 0x00000001106d307c Realm`(anonymous namespace)::IncrementalChangeInfo::advance_to_final(this=0x0000700009caf748, version=(version = 9, index = 8)) + 124 at realm_coordinator.cpp:468
    frame #9: 0x00000001106d1162 Realm`realm::_impl::RealmCoordinator::run_async_notifiers(this=0x00007ff489e36cf0) + 7106 at realm_coordinator.cpp:587
    frame #10: 0x00000001106cf325 Realm`realm::_impl::RealmCoordinator::on_change(this=0x00007ff489e36cf0) + 37 at realm_coordinator.cpp:410
    frame #11: 0x000000011067862f Realm`realm::_impl::ExternalCommitHelper::listen(this=0x0000608000446de0) + 735 at external_commit_helper.cpp:217
    frame #12: 0x000000011067cf87 Realm`realm::_impl::ExternalCommitHelper::ExternalCommitHelper(this=0x0000608000521c10)::$_0::operator()() const + 23 at external_commit_helper.cpp:159
    frame #13: 0x000000011067cf5d Realm`_ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE [inlined] std::__1::__invoke<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(__f=0x0000608000521c10)::$_0>(fp)(std::__1::forward<>(fp0))), realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0&&) + 61 at __functional_base:416
    frame #14: 0x000000011067cf4c Realm`_ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE(this=0x0000608000521c10, (null)=__tuple_indices<> @ 0x0000700009cb0c20) + 44 at future:2348
    frame #15: 0x000000011067cf15 Realm`std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator(this=0x0000608000521c10)() + 21 at future:2341
    frame #16: 0x000000011067ce3f Realm`std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::__execute(this=0x0000608000521b80) + 31 at future:1031
    frame #17: 0x000000011067d8b4 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) [inlined] std::__1::__invoke<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*, void>(__f=0x0000608000428300, __a0=0x0000608000428310)::$_0> >*>(fp0)).*fp(std::__1::forward<>(fp1))), void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*&&)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*&&) + 127 at __functional_base:383
    frame #18: 0x000000011067d835 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) [inlined] _ZNSt3__116__thread_executeIMNS_19__async_assoc_stateIvNS_12__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS4_16RealmCoordinatorEE3$_0JEEEEEFvvEJPSA_EJLm1EEEEvRNS_5tupleIJT_DpT0_EEENS_15__tuple_indicesIJXspT1_EEEE(__t=0x0000608000428300) + 40 at thread:347
    frame #19: 0x000000011067d80d Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(__vp=0x0000608000428300) + 365 at thread:357
    frame #20: 0x0000000115922aab libsystem_pthread.dylib`_pthread_body + 180
    frame #21: 0x00000001159229f7 libsystem_pthread.dylib`_pthread_start + 286
    frame #22: 0x0000000115922221 libsystem_pthread.dylib`thread_start + 13

@4np
Copy link

4np commented Dec 16, 2016

Same here; I've just encountered this as well in tvOS / Xcode 8.2 / Swift (Cocoapods dependency manager). I was Googling for hints and found this issue :)

uncaught exception in notifier thread: N5realm10LogicErrorE: Bad version number

@jpsim
Copy link
Contributor

jpsim commented Dec 16, 2016

We'd love to address this, but to make progress we'll likely need a sample project that reproduces this issue. Can anyone who's experienced this provide us with steps to trigger?

@parghki-mfcgd
Copy link

parghki-mfcgd commented Dec 19, 2016

I have faced this same problem when i update my carthage file:

carthage update --toolchain com.apple.dt.toolchain.Swift_2_3 --no-use-binaries --platform iOS

My cart file contains:

github "realm/realm-cocoa"

I got uncaught exception in "group_shared.hpp" file.

 inline void SharedGroup::advance_read(O* observer, VersionID version_id)
  {
    if (m_transact_stage != transact_Reading)
        throw LogicError(LogicError::wrong_transact_state); <---

    // It is an error if the new version precedes the currently bound one.
    if (version_id.version < m_read_lock.m_version)
        throw LogicError(LogicError::bad_version);

    _impl::History* hist = get_history(); // Throws
    if (!hist)
        throw LogicError(LogicError::no_history);

    do_advance_read(observer, version_id, *hist); // Throws
}

I throws this exception : LogicError(LogicError::bad_version)

@jpsim
Copy link
Contributor

jpsim commented Dec 19, 2016

@kirtiparghi can you share a project that triggers this? What you shared is a way to install Realm, which we're familiar with already, and is not at fault here.

@TimOliver
Copy link
Contributor

Just a quick ping of this issue. If anyone can provide us with a project that triggers this issue, that would be much appreciated. Thanks a lot! :)

Happy holidays!

@thombles
Copy link

Hullo Tim and team, I'm seeing this intermittently with the realm.refresh() in the following code, running Realm 2.1.2 on the simulator: uncaught exception in notifier thread: N5realm10LogicErrorE: Bad version number

It seems to happen more often if I take out the NSLog statements...

I added the refresh() because these image URLs are often being set while my UIScrollView is blocking the main runloop. Not sure whether that's a good solution but it's introduced this new issue. :)

class NetImage: UIImageView {
    
    fileprivate var queryResult: Results<DownloadedBinary>?
    fileprivate var token: NotificationToken?
    
    var url: String? {
        willSet(newUrl) {
            // If the URL is changing, clear out our existing image
            if newUrl != self.url {
                self.image = nil
            }
        }
        didSet {
            if let url = self.url {
                let realm = try! Realm()
                queryResult = realm.objects(DownloadedBinary.self).filter("url = %@", url)
                self.token = self.queryResult?.addNotificationBlock() {
                    change in
                    self.updateFromQuery()
                }
                NSLog("Before")
                realm.refresh()
                NSLog("After")
            } else {
                self.image = nil
            }
        }
    }
    // ...
}

That code is running on thread 1. The exception is occurring in The RLMRealm notification listener thread (thread 8 in my test) with this backtrace

(lldb) bt
* thread #8: tid = 0xbcc2c8, 0x0000000114a6f867 libc++abi.dylib`__cxa_throw, name = 'RLMRealm notification listener', stop reason = breakpoint 1.2
    frame #0: 0x0000000114a6f867 libc++abi.dylib`__cxa_throw
  * frame #1: 0x00000001101dcc3c Realm`void realm::SharedGroup::advance_read<(anonymous namespace)::TransactLogValidator>(this=0x00007fa01283fc00, observer=0x0000700007b2ca88, version_id=(version = 7, index = 6))::TransactLogValidator*, realm::VersionID) + 220 at group_shared.hpp:915
    frame #2: 0x00000001101dcb4b Realm`void realm::_impl::SharedGroupFriend::advance_read<(anonymous namespace)::TransactLogValidator>(sg=0x00007fa01283fc00, obs=0x0000700007b2ca88, ver=(version = 7, index = 6))::TransactLogValidator*, realm::VersionID) + 59 at group_shared.hpp:1086
    frame #3: 0x00000001101dcafb Realm`void realm::LangBindHelper::advance_read<(anonymous namespace)::TransactLogValidator>(sg=0x00007fa01283fc00, observer=0x0000700007b2ca88, version=(version = 7, index = 6))::TransactLogValidator&&, realm::VersionID) + 59 at lang_bind_helper.hpp:335
    frame #4: 0x00000001101dc485 Realm`auto realm::_impl::transaction::advance(this=0x0000700007b2ce60, args=0x0000700007b2ca88)::$_0::operator()<(anonymous namespace)::TransactLogValidator>((anonymous namespace)::TransactLogValidator&&) const + 69 at transact_log_handler.cpp:823
    frame #5: 0x00000001101dbd9e Realm`(anonymous namespace)::TransactLogObserver::TransactLogObserver<realm::_impl::transaction::advance(this=0x0000700007b2ce70, context=0x0000000000000000, sg=0x00007fa01283fc00, func=0x0000700007b2ce60, schema_mode=Optional<realm::SchemaMode> @ 0x0000700007b2ce58, notifiers=0x0000700007b2cee8)::$_0>(realm::BindingContext*, realm::SharedGroup&, realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID)::$_0&&, realm::util::Optional<realm::SchemaMode>, realm::_impl::NotifierPackage&) + 1022 at transact_log_handler.cpp:274
    frame #6: 0x00000001101d5905 Realm`(anonymous namespace)::TransactLogObserver::TransactLogObserver<realm::_impl::transaction::advance(this=0x0000700007b2ce70, context=0x0000000000000000, sg=0x00007fa01283fc00, func=0x0000700007b2ce60, schema_mode=<unavailable>, notifiers=0x0000700007b2cee8)::$_0>(realm::BindingContext*, realm::SharedGroup&, realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID)::$_0&&, realm::util::Optional<realm::SchemaMode>, realm::_impl::NotifierPackage&) + 53 at transact_log_handler.cpp:262
    frame #7: 0x00000001101d5855 Realm`realm::_impl::transaction::advance(sg=0x00007fa01283fc00, context=0x0000000000000000, schema_mode=Automatic, version=(version = 7, index = 6)) + 149 at transact_log_handler.cpp:822
    frame #8: 0x000000010ff9419c Realm`(anonymous namespace)::IncrementalChangeInfo::advance_to_final(this=0x0000700007b2d748, version=(version = 7, index = 6)) + 124 at realm_coordinator.cpp:468
    frame #9: 0x000000010ff92282 Realm`realm::_impl::RealmCoordinator::run_async_notifiers(this=0x00007fa01250b340) + 7106 at realm_coordinator.cpp:587
    frame #10: 0x000000010ff90445 Realm`realm::_impl::RealmCoordinator::on_change(this=0x00007fa01250b340) + 37 at realm_coordinator.cpp:410
    frame #11: 0x000000010ff3974f Realm`realm::_impl::ExternalCommitHelper::listen(this=0x0000608000244800) + 735 at external_commit_helper.cpp:217
    frame #12: 0x000000010ff3e0a7 Realm`realm::_impl::ExternalCommitHelper::ExternalCommitHelper(this=0x0000608000338230)::$_0::operator()() const + 23 at external_commit_helper.cpp:159
    frame #13: 0x000000010ff3e07d Realm`_ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE [inlined] std::__1::__invoke<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(__f=0x0000608000338230)::$_0>(fp)(std::__1::forward<>(fp0))), realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0&&) + 61 at __functional_base:416
    frame #14: 0x000000010ff3e06c Realm`_ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE(this=0x0000608000338230, (null)=__tuple_indices<> @ 0x0000700007b2ec20) + 44 at future:2348
    frame #15: 0x000000010ff3e035 Realm`std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator(this=0x0000608000338230)() + 21 at future:2341
    frame #16: 0x000000010ff3df5f Realm`std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::__execute(this=0x00006080003381a0) + 31 at future:1031
    frame #17: 0x000000010ff3e9d4 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) [inlined] std::__1::__invoke<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*, void>(__f=0x000060800023d080, __a0=0x000060800023d090)::$_0> >*>(fp0)).*fp(std::__1::forward<>(fp1))), void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*&&)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*&&) + 127 at __functional_base:383
    frame #18: 0x000000010ff3e955 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) [inlined] _ZNSt3__116__thread_executeIMNS_19__async_assoc_stateIvNS_12__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS4_16RealmCoordinatorEE3$_0JEEEEEFvvEJPSA_EJLm1EEEEvRNS_5tupleIJT_DpT0_EEENS_15__tuple_indicesIJXspT1_EEEE(__t=0x000060800023d080) + 40 at thread:347
    frame #19: 0x000000010ff3e92d Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(__vp=0x000060800023d080) + 365 at thread:357
    frame #20: 0x0000000114f3eaab libsystem_pthread.dylib`_pthread_body + 180
    frame #21: 0x0000000114f3e9f7 libsystem_pthread.dylib`_pthread_start + 286
    frame #22: 0x0000000114f3e221 libsystem_pthread.dylib`thread_start + 13

screen shot 2016-12-24 at 4 10 39 pm

@gralexey
Copy link

gralexey commented Dec 26, 2016

I encounter this bug using my app with realm 1.0.2 right after I update Realm up to 2.1.1. It causes db update listener to break.

UPD: according to our testers, it breaks even on pure 2.1.1 (without any updating from 1.0.2 to 2.1.1)

@jk2K
Copy link

jk2K commented Dec 29, 2016

I'm having the same issue, realm version: 2.1.1

@noder199
Copy link

noder199 commented Jan 4, 2017

First I got a -[__NSArrayM insertObject:atIndex:]: object cannot be nil error then I set an exception breakpoint to try to get this error again but instead I keep getting this N5realm10LogicErrorE: Bad version number exception.

Edit: On further investigation, I see that the the array problem is unrelated.
I am using RealmSwift realm version 2.1.1

@joninsky
Copy link

joninsky commented Jan 6, 2017

Ok, I came across this issue as I was trying to figure out why my Realm file was ballooning to over a gigabyte sometimes.

Here is where I am at:

  • I am using Realm as a dependency in a Networking framework that I am writing in Swift.
  • I don't want my frameworks Realm to interfere with my frameworks' users Realm so I make sure I make and configure my own realm file.
  • All interaction with realm is hidden as best as it can from the user of my framework. To accomplish this set up I make the user initialize a shared configuration object.

I was running into these problems:

  • Random balloons to over 1 GB in data. This seemed to happen when migrating between realm versions and when I passed deleteRealmIfMigrationNeeded: true as a parameter for experimentation.
  • At some point, my app started throwing the "N5realm10LogicErrorE: Bad version number." I think it was when I started passing deleteRealmIfMigrationNeeded: true as a configuration parameter. Since then the error always gets thrown.

Here is the stack trace from that exception:

* thread #9: tid = 0xec9dd, 0x0000000183162efc libc++abi.dylib`__cxa_throw, name = 'RLMRealm notification listener', stop reason = breakpoint 1.2
    frame #0: 0x0000000183162efc libc++abi.dylib`__cxa_throw
  * frame #1: 0x00000001007c1f50 Realm`void realm::SharedGroup::advance_read<(anonymous namespace)::TransactLogValidator>(this=0x000000010208be00, observer=0x000000016e26c960, version_id=(version = 8884, index = 16))::TransactLogValidator*, realm::VersionID) + 220 at group_shared.hpp:915
    frame #2: 0x00000001007c1e68 Realm`void realm::_impl::SharedGroupFriend::advance_read<(anonymous namespace)::TransactLogValidator>(sg=0x000000010208be00, obs=0x000000016e26c960, ver=(version = 8884, index = 16))::TransactLogValidator*, realm::VersionID) + 64 at group_shared.hpp:1086
    frame #3: 0x00000001007c1e1c Realm`void realm::LangBindHelper::advance_read<(anonymous namespace)::TransactLogValidator>(sg=0x000000010208be00, observer=0x000000016e26c960, version=(version = 8884, index = 16))::TransactLogValidator&&, realm::VersionID) + 64 at lang_bind_helper.hpp:335
    frame #4: 0x00000001007c1878 Realm`auto realm::_impl::transaction::advance(this=0x000000016e26cd80, args=0x000000016e26c960)::$_0::operator()<(anonymous namespace)::TransactLogValidator>((anonymous namespace)::TransactLogValidator&&) const + 72 at transact_log_handler.cpp:823
    frame #5: 0x00000001007c138c Realm`(anonymous namespace)::TransactLogObserver::TransactLogObserver<realm::_impl::transaction::advance(this=0x000000016e26cd90, context=0x0000000000000000, sg=0x000000010208be00, func=0x000000016e26cd80, schema_mode=<unavailable>, notifiers=0x000000016e26ce08)::$_0>(realm::BindingContext*, realm::SharedGroup&, realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID)::$_0&&, realm::util::Optional<realm::SchemaMode>, realm::_impl::NotifierPackage&) + 672 at transact_log_handler.cpp:274
    frame #6: 0x00000001007bb1f0 Realm`(anonymous namespace)::TransactLogObserver::TransactLogObserver<realm::_impl::transaction::advance(this=0x000000016e26cd90, context=0x0000000000000000, sg=0x000000010208be00, func=0x000000016e26cd80, schema_mode=<unavailable>, notifiers=0x000000016e26ce08)::$_0>(realm::BindingContext*, realm::SharedGroup&, realm::_impl::transaction::advance(realm::SharedGroup&, realm::BindingContext*, realm::SchemaMode, realm::VersionID)::$_0&&, realm::util::Optional<realm::SchemaMode>, realm::_impl::NotifierPackage&) + 60 at transact_log_handler.cpp:262
    frame #7: 0x00000001007bb124 Realm`realm::_impl::transaction::advance(sg=0x000000010208be00, context=0x0000000000000000, schema_mode=ResetFile, version=(version = 8884, index = 16)) + 140 at transact_log_handler.cpp:822
    frame #8: 0x00000001005e8e60 Realm`(anonymous namespace)::IncrementalChangeInfo::advance_to_final(this=0x000000016e26d700, version=(version = 8884, index = 16)) + 116 at realm_coordinator.cpp:468
    frame #9: 0x00000001005e78c4 Realm`realm::_impl::RealmCoordinator::run_async_notifiers(this=0x0000000101e4d9b8) + 4668 at realm_coordinator.cpp:587
    frame #10: 0x00000001005e6498 Realm`realm::_impl::RealmCoordinator::on_change(this=0x0000000101e4d9b8) + 40 at realm_coordinator.cpp:410
    frame #11: 0x00000001005992bc Realm`realm::_impl::ExternalCommitHelper::listen(this=0x0000000101e4a020) + 648 at external_commit_helper.cpp:217
    frame #12: 0x000000010059d54c Realm`realm::_impl::ExternalCommitHelper::ExternalCommitHelper(this=0x0000000101e4c2e0)::$_0::operator()() const + 24 at external_commit_helper.cpp:159
    frame #13: 0x000000010059d528 Realm`_ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE [inlined] std::__1::__invoke<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(__f=0x0000000101e4c2e0)::$_0>(fp)(std::__1::forward<>(fp0))), realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0&&) + 64 at __functional_base:416
    frame #14: 0x000000010059d518 Realm`_ZNSt3__112__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEE9__executeIJEEEvNS_15__tuple_indicesIJXspT_EEEE(this=0x0000000101e4c2e0, (null)=__tuple_indices<> @ 0x000000016e26ec10) + 48 at future:2348
    frame #15: 0x000000010059d4dc Realm`std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator(this=0x0000000101e4c2e0)() + 24 at future:2341
    frame #16: 0x000000010059d3ec Realm`std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::__execute(this=0x0000000101e4c250) + 32 at future:1031
    frame #17: 0x000000010059dc70 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) [inlined] std::__1::__invoke<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*, void>(__f=0x0000000101e50ad0, __a0=0x0000000101e50ae0)::$_0> >*>(fp0)).*fp(std::__1::forward<>(fp1))), void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*&&)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*&&) + 100 at __functional_base:383
    frame #18: 0x000000010059dc0c Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) [inlined] _ZNSt3__116__thread_executeIMNS_19__async_assoc_stateIvNS_12__async_funcIZN5realm5_impl20ExternalCommitHelperC1ERNS4_16RealmCoordinatorEE3$_0JEEEEEFvvEJPSA_EJLm1EEEEvRNS_5tupleIJT_DpT0_EEENS_15__tuple_indicesIJXspT1_EEEE(__t=0x0000000101e50ad0) + 40 at thread:347
    frame #19: 0x000000010059dbe4 Realm`std::__1::__thread_proxy<std::__1::tuple<void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(__vp=0x0000000101e50ad0) + 248 at thread:357
    frame #20: 0x00000001837d1850 libsystem_pthread.dylib`_pthread_body + 240
    frame #21: 0x00000001837d1760 libsystem_pthread.dylib`_pthread_start + 284
    frame #22: 0x00000001837ced94 libsystem_pthread.dylib`thread_start + 4

I can't share my code where this error is currently happening. I did make an example project that uses my Configuration object to make and manage my the Realm.

That project is clonable/downloadable here.

Just run good old pod install

I was not able to get this demo project to throw the "N5realm10LogicErrorE: Bad version number" error. If I do, I will post an edit with my steps.

This project does demonstrate the ballooning of my Realm file especially when the version is ticked over and the deleteRealmIfMigrationNeeded: true is set.

Check out my demo app and let me know if I am using Realm wrong in any way, I would really appreciate any feedback as I love the software but am concerned about these little/big issues I keep running into.

Also, if my ballooning issue warrants its own issue let me know and I will move it/file it appropriately. Hopefully, I am just miss using something or not understanding this.

@tgoyne
Copy link
Member

tgoyne commented Jan 19, 2017

This should be fixed by realm/realm-object-store#355.

@tbaranes
Copy link

tbaranes commented Jan 27, 2017

Realm v2.4.0 seems to fix that warning for me.

@joninsky
Copy link

v2.4.0 Fixed this for me also.

@Ankit-Aggarwal
Copy link

Again getting this issue in v2.4.2, is it working fine for others ?

@jpsim
Copy link
Contributor

jpsim commented Feb 16, 2017

@Ankit-Aggarwal please file a new issue taking care to fill out the template with as much relevant information as possible. Thanks.

@realm realm locked and limited conversation to collaborators Feb 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests