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

Crash at Realm(fileURL: ) with access group. #4221

Closed
Ankish opened this issue Oct 14, 2016 · 12 comments
Closed

Crash at Realm(fileURL: ) with access group. #4221

Ankish opened this issue Oct 14, 2016 · 12 comments

Comments

@Ankish
Copy link

Ankish commented Oct 14, 2016

Using Real with Keyboard Extension - so using access group

Fetching by :

if let realm = try? Realm(fileURL: NSURL(string: RealmConfig.dbPath)!)
class RealmConfig {

  static var dbPath: String {
    let url = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.com.xx.kexx")

    return url!.URLByAppendingPathComponent("db50.realm").path!
  }

}

Crashes at first Realm code:

public convenience init(fileURL: NSURL) throws {
    var configuration = Configuration.defaultConfiguration
    configuration.fileURL = fileURL
    try self.init(configuration: configuration)
}

Stack trace

#0  0x00000001826dcc38 in flock ()
#1  0x0000000100bbba0c in realm::util::File::lock(bool, bool) ()
#2  0x0000000100c71794 in realm::SharedGroup::do_open(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, realm::SharedGroup::DurabilityLevel, bool, char const*, bool) ()
#3  0x0000000100b844f0 in realm::SharedGroup::open(realm::Replication&, realm::SharedGroup::DurabilityLevel, char const*, bool) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/core/realm/group_shared.hpp:836
#4  0x0000000100b841a8 in realm::SharedGroup::SharedGroup(realm::Replication&, realm::SharedGroup::DurabilityLevel, char const*, bool, std::__1::function<void (int, int)>) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/core/realm/group_shared.hpp:805
#5  0x0000000100b83cb0 in realm::SharedGroup::SharedGroup(realm::Replication&, realm::SharedGroup::DurabilityLevel, char const*, bool, std::__1::function<void (int, int)>) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/core/realm/group_shared.hpp:804
#6  0x0000000100b783f4 in std::__1::__unique_if<realm::SharedGroup>::__unique_single std::__1::make_unique<realm::SharedGroup, realm::Replication&, realm::SharedGroup::DurabilityLevel&, char const*, bool, realm::Realm::open_with_config(realm::Realm::Config const&, std::__1::unique_ptr<realm::Replication, std::__1::default_delete<realm::Replication> >&, std::__1::unique_ptr<realm::SharedGroup, std::__1::default_delete<realm::SharedGroup> >&, std::__1::unique_ptr<realm::Group, std::__1::default_delete<realm::Group> >&, realm::Realm*)::$_0>(realm::Replication&&&, realm::SharedGroup::DurabilityLevel&&&, char const*&&, bool&&, realm::Realm::open_with_config(realm::Realm::Config const&, std::__1::unique_ptr<realm::Replication, std::__1::default_delete<realm::Replication> >&, std::__1::unique_ptr<realm::SharedGroup, std::__1::default_delete<realm::SharedGroup> >&, std::__1::unique_ptr<realm::Group, std::__1::default_delete<realm::Group> >&, realm::Realm*)::$_0&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3132
#7  0x0000000100b78360 in realm::Realm::open_with_config(realm::Realm::Config const&, std::__1::unique_ptr<realm::Replication, std::__1::default_delete<realm::Replication> >&, std::__1::unique_ptr<realm::SharedGroup, std::__1::default_delete<realm::SharedGroup> >&, std::__1::unique_ptr<realm::Group, std::__1::default_delete<realm::Group> >&, realm::Realm*) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/Realm/ObjectStore/src/shared_realm.cpp:150
#8  0x0000000100b77888 in realm::Realm::Realm(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/Realm/ObjectStore/src/shared_realm.cpp:42
#9  0x0000000100a1125c in realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler::make_shared_enabler(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/shared_realm.hpp:262
#10 0x0000000100a111e4 in realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler::make_shared_enabler(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/shared_realm.hpp:262
#11 0x0000000100a10d08 in std::__1::__libcpp_compressed_pair_imp<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>, realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler, 1u>::__libcpp_compressed_pair_imp<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&, realm::Realm::Config&&, 0ul, 0ul>(std::__1::piecewise_construct_t, std::__1::tuple<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&>, std::__1::tuple<realm::Realm::Config&&>, std::__1::__tuple_indices<0ul>, std::__1::__tuple_indices<0ul>) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2185
#12 0x0000000100a10cc0 in std::__1::__compressed_pair<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>, realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>::__compressed_pair<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&, realm::Realm::Config&&>(std::__1::piecewise_construct_t, std::__1::tuple<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&>, std::__1::tuple<realm::Realm::Config&&>) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2448
#13 0x0000000100a10c90 in std::__1::__compressed_pair<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>, realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>::__compressed_pair<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&, realm::Realm::Config&&>(std::__1::piecewise_construct_t, std::__1::tuple<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&>, std::__1::tuple<realm::Realm::Config&&>) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2451
#14 0x0000000100a10c78 in std::__1::__shared_ptr_emplace<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler, std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler> >::__shared_ptr_emplace<realm::Realm::Config>(std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>, realm::Realm::Config&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3791
#15 0x0000000100a10b44 in std::__1::__shared_ptr_emplace<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler, std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler> >::__shared_ptr_emplace<realm::Realm::Config>(std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>, realm::Realm::Config&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3792
#16 0x0000000100a10b34 in std::__1::shared_ptr<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler> std::__1::shared_ptr<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>::make_shared<realm::Realm::Config>(realm::Realm::Config&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4385
#17 0x0000000100a0eab0 in std::__1::enable_if<!(is_array<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>::value), std::__1::shared_ptr<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler> >::type std::__1::make_shared<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler, realm::Realm::Config>(realm::Realm::Config&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4749
#18 0x0000000100a0ea94 in realm::Realm::make_shared_realm(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/shared_realm.hpp:264
#19 0x0000000100a0352c in realm::_impl::RealmCoordinator::get_realm(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/Realm/ObjectStore/src/impl/realm_coordinator.cpp:101
#20 0x0000000100b7ad2c in realm::Realm::get_shared_realm(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/Realm/ObjectStore/src/shared_realm.cpp:183
#21 0x0000000100b50bf4 in +[RLMRealm realmWithConfiguration:error:] at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/Realm/RLMRealm.mm:271
#22 0x00000001010987fc in @nonobjc RLMRealm.__allocating_init(configuration : RLMRealmConfiguration) throws -> RLMRealm ()
#23 0x0000000101095e54 in Realm.init(configuration : Realm.Configuration) throws -> Realm at /Users/ankish/Work/Cipher/Working/ankish/Pods/RealmSwift/RealmSwift/Realm.swift:693
#24 0x0000000101096448 in Realm.init(fileURL : NSURL) throws -> Realm at /Users/ankish/Work/Cipher/Working/ankish/Pods/RealmSwift/RealmSwift/Realm.swift:707
#25 0x000000010109662c in Realm.__allocating_init(fileURL : NSURL) throws -> Realm ()
#26 0x0000000100194dd8 in static Session.getSessionWithSessionId(String) -> Session? at /Users/ankish/Work/Cipher/Working/ankish/HostingApp/Sources/Model/RealmModels.swift:113
#27 0x0000000100100018 in static CipherED.getValidDecryptedString(String, completion : (Result<String, SessionError>) -> ()) -> () at /Users/ankish/Work/Cipher/Working/ankish/Keyboard/CipherED.swift:133
#28 0x00000001001aa6ec in KeyboardViewController.poolTimerTick() -> () at /Users/ankish/Work/Cipher/Working/ankish/Keyboard/KeyboardViewController.swift:1002
#29 0x00000001001aa798 in @objc KeyboardViewController.poolTimerTick() -> () ()
#30 0x0000000183531038 in __NSFireTimer ()
#31 0x0000000182b11794 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#32 0x0000000182b11438 in __CFRunLoopDoTimer ()
#33 0x0000000182b0eb4c in __CFRunLoopRun ()
#34 0x0000000182a38c50 in CFRunLoopRunSpecific ()
#35 0x0000000184320088 in GSEventRunModal ()
#36 0x0000000187d22088 in UIApplicationMain ()
#37 0x00000001827fcce0 in _xpc_objc_main ()
#38 0x00000001827fe9dc in xpc_main ()
#39 0x000000018361bd60 in -[NSXPCListener resume] ()
#40 0x0000000189e5ec48 in -[PKService run] ()
#41 0x0000000189e5e8dc in +[PKService main] ()
#42 0x0000000189e5ec6c in +[PKService _defaultRun:arguments:] ()
#43 0x000000018342e058 in NSExtensionMain ()
#44 0x00000001825d68b8 in start ()

Steps to Reproduce

Realm version: ?
- Realm (1.1.0):
    - Realm/Headers (= 1.1.0)
  - Realm/Headers (1.1.0)
  - RealmSwift (1.1.0):
    - Realm (= 1.1.0)

Xcode version: 7.3.1

iOS/OSX version: 9.3.3

Dependency manager + version: CocoaPods (unknown version)

@stel
Copy link
Contributor

stel commented Oct 14, 2016

@Ankish thank you for sharing this crash report!

Could you please provide some more info how to reproduce this crash, error message you see or example Xcode project, thanks!

@Ankish
Copy link
Author

Ankish commented Oct 14, 2016

@stel I havent still seen this crash on iPhone 5s 9.3.5 - I am seeing this on 6s 9.3.3. Havent tested on all other devices. It does not crash always on initializing the Realm object. If I was able produce this consistently I could have prepared a sample project and pointed the issue. I am not able to reproduce it every time.

however its a simple code:

class func getSessionWithSessionId(sessionId : String ) -> Session?{
  let realm = try! Realm(fileURL: NSURL(string: RealmConfig.dbPath)!) // crashes here on keyboard extension
  let predicate = NSPredicate(format: "sessionID = %@",sessionId)
  let collection = realm.objects(Session.self).filter(predicate)
  if collection.count == 0 {
    return nil
  }
  return collection.first!
}

@jpsim
Copy link
Contributor

jpsim commented Oct 17, 2016

Hi @Ankish, we've made some improvements to the interprocess locking mechanism in recent Realm versions. Could you please try with the latest release to see if that improves things? That's Realm 2.0.2 as of this writing.

@jpsim
Copy link
Contributor

jpsim commented Nov 9, 2016

@Ankish just following up on my request for you to see if recent Realm versions still exhibit this issue (latest version is 2.0.3 as of this writing).

@jpsim
Copy link
Contributor

jpsim commented Dec 7, 2016

Closing as we never heard back from @Ankish and I suspect this has been fixed since the issue was reported.

@Ankish
Copy link
Author

Ankish commented Jan 6, 2017

I see it ocassionaly.

Thread 1Queue : com.apple.main-thread (serial)
#0	0x0000000182524c38 in flock ()
#1	0x0000000100d43a90 in realm::util::File::lock(bool, bool) ()
#2	0x0000000100df9958 in realm::SharedGroup::do_open(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, realm::SharedGroup::DurabilityLevel, bool, char const*, bool) ()
#3	0x0000000100d0b034 in realm::SharedGroup::open(realm::Replication&, realm::SharedGroup::DurabilityLevel, char const*, bool) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/core/realm/group_shared.hpp:836
#4	0x0000000100d0acf4 in realm::SharedGroup::SharedGroup(realm::Replication&, realm::SharedGroup::DurabilityLevel, char const*, bool, std::__1::function<void (int, int)>) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/core/realm/group_shared.hpp:805
#5	0x0000000100d09aac in realm::SharedGroup::SharedGroup(realm::Replication&, realm::SharedGroup::DurabilityLevel, char const*, bool, std::__1::function<void (int, int)>) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/core/realm/group_shared.hpp:804
#6	0x0000000100d01138 in std::__1::__unique_if<realm::SharedGroup>::__unique_single std::__1::make_unique<realm::SharedGroup, realm::Replication&, realm::SharedGroup::DurabilityLevel&, char const*, bool, realm::Realm::open_with_config(realm::Realm::Config const&, std::__1::unique_ptr<realm::Replication, std::__1::default_delete<realm::Replication> >&, std::__1::unique_ptr<realm::SharedGroup, std::__1::default_delete<realm::SharedGroup> >&, std::__1::unique_ptr<realm::Group, std::__1::default_delete<realm::Group> >&, realm::Realm*)::$_0>(realm::Replication&&&, realm::SharedGroup::DurabilityLevel&&&, char const*&&, bool&&, realm::Realm::open_with_config(realm::Realm::Config const&, std::__1::unique_ptr<realm::Replication, std::__1::default_delete<realm::Replication> >&, std::__1::unique_ptr<realm::SharedGroup, std::__1::default_delete<realm::SharedGroup> >&, std::__1::unique_ptr<realm::Group, std::__1::default_delete<realm::Group> >&, realm::Realm*)::$_0&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3141
#7	0x0000000100d010a4 in realm::Realm::open_with_config(realm::Realm::Config const&, std::__1::unique_ptr<realm::Replication, std::__1::default_delete<realm::Replication> >&, std::__1::unique_ptr<realm::SharedGroup, std::__1::default_delete<realm::SharedGroup> >&, std::__1::unique_ptr<realm::Group, std::__1::default_delete<realm::Group> >&, realm::Realm*) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/Realm/ObjectStore/src/shared_realm.cpp:150
#8	0x0000000100d005d4 in realm::Realm::Realm(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/Realm/ObjectStore/src/shared_realm.cpp:42
#9	0x0000000100b9b008 in realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler::make_shared_enabler(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/shared_realm.hpp:262
#10	0x0000000100b9af90 in realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler::make_shared_enabler(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/shared_realm.hpp:262
#11	0x0000000100b9a90c in std::__1::__libcpp_compressed_pair_imp<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>, realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler, 1u>::__libcpp_compressed_pair_imp<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&, realm::Realm::Config&&, 0ul, 0ul>(std::__1::piecewise_construct_t, std::__1::tuple<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&>, std::__1::tuple<realm::Realm::Config&&>, std::__1::__tuple_indices<0ul>, std::__1::__tuple_indices<0ul>) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2194
#12	0x0000000100b9a8c4 in std::__1::__compressed_pair<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>, realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>::__compressed_pair<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&, realm::Realm::Config&&>(std::__1::piecewise_construct_t, std::__1::tuple<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&>, std::__1::tuple<realm::Realm::Config&&>) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2457
#13	0x0000000100b9a894 in std::__1::__compressed_pair<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>, realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>::__compressed_pair<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&, realm::Realm::Config&&>(std::__1::piecewise_construct_t, std::__1::tuple<std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>&>, std::__1::tuple<realm::Realm::Config&&>) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2460
#14	0x0000000100b9a87c in std::__1::__shared_ptr_emplace<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler, std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler> >::__shared_ptr_emplace<realm::Realm::Config>(std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>, realm::Realm::Config&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3800
#15	0x0000000100b9a748 in std::__1::__shared_ptr_emplace<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler, std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler> >::__shared_ptr_emplace<realm::Realm::Config>(std::__1::allocator<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>, realm::Realm::Config&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3801
#16	0x0000000100b9a738 in std::__1::shared_ptr<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler> std::__1::shared_ptr<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>::make_shared<realm::Realm::Config>(realm::Realm::Config&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4411
#17	0x0000000100b91018 in std::__1::enable_if<!(is_array<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler>::value), std::__1::shared_ptr<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler> >::type std::__1::make_shared<realm::Realm::make_shared_realm(realm::Realm::Config)::make_shared_enabler, realm::Realm::Config>(realm::Realm::Config&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4775
#18	0x0000000100b90ffc in realm::Realm::make_shared_realm(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/include/shared_realm.hpp:264
#19	0x0000000100b90630 in realm::_impl::RealmCoordinator::get_realm(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/Realm/ObjectStore/src/impl/realm_coordinator.cpp:101
#20	0x0000000100d03afc in realm::Realm::get_shared_realm(realm::Realm::Config) at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/Realm/ObjectStore/src/shared_realm.cpp:183
#21	0x0000000100cda058 in +[RLMRealm realmWithConfiguration:error:] at /Users/ankish/Work/Cipher/Working/ankish/Pods/Realm/Realm/RLMRealm.mm:271
#22	0x000000010121e1f4 in @nonobjc RLMRealm.__allocating_init(configuration : RLMRealmConfiguration) throws -> RLMRealm ()
#23	0x000000010121e44c in Realm.init(configuration : Realm.Configuration) throws -> Realm at /Users/ankish/Work/Cipher/Working/ankish/Pods/RealmSwift/RealmSwift/Realm.swift:693
#24	0x000000010121ea10 in Realm.init(fileURL : NSURL) throws -> Realm at /Users/ankish/Work/Cipher/Working/ankish/Pods/RealmSwift/RealmSwift/Realm.swift:707
#25	0x000000010121ebd4 in Realm.__allocating_init(fileURL : NSURL) throws -> Realm ()
#26	0x0000000100279258 in static Cache.getCacheWithKey(String) -> Cache? at /Users/ankish/Work/Cipher/Working/ankish/HostingApp/Sources/Model/RealmModels.swift:329

@bdash
Copy link
Contributor

bdash commented Jan 6, 2017

@Ankish, can you share more information about the crash? The backtrace only tells us where the crash happened, not what went wrong.

@bdash
Copy link
Contributor

bdash commented Jan 6, 2017

@Ankish, of particular interest is the portion of LLDB's output that looks something like this:

* thread #1: tid = 0x1bb2edc, 0x000000010765ccbd libobjc.A.dylib`objc_retain + 13, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xe)

@Ankish
Copy link
Author

Ankish commented Jan 6, 2017

I might be accessing Realm from main thread as well as from an background thread. Is that safety guaranteed ?

@bdash
Copy link
Contributor

bdash commented Jan 6, 2017

@Ankish, can you please provide the full crash log or debugger output rather than just a partial snippet? The missing portions of the output contain important information that will help us understand the problem.

@onmyway133
Copy link

onmyway133 commented Jul 11, 2017

If you use realm file in bundle, it will crash on the device. Need to specify readonly

readOnly: Whether the Realm is read-only (must be true for read-only files).

let path = Bundle.main.url(forResource: "mydata", withExtension: "realm")!
let configuration = Realm.Configuration(fileURL: path, readOnly: true)
realm = try! Realm(configuration: configuration)

@tkafka
Copy link

tkafka commented Sep 25, 2022

@onmyway133 Hi, found this due to similar crash here in 2022 - is there a solution when you want to write from the extension as well?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
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

7 participants