arturdev / Unrealm

Unrealm is an extension on RealmCocoa, which enables Swift native types to be saved in Realm.
MIT License
537 stars 72 forks source link

Realm program crashes while opening realm database #32

Closed lingolab2 closed 4 years ago

lingolab2 commented 4 years ago

program crashes when trying to open realm database.

        let config = Realm.Configuration(fileURL: destinationURL,
                                         readOnly: false,
                                         schemaVersion: 1,
                                         migrationBlock: { (migration, oldSchemaVersion) in
                                            if (oldSchemaVersion < 1) {

                                            }
        })
        let realm: Realm = {
            return try! Realm(configuration: config)
        }()

The debugger gives me a hint that it is in the object table Kanji and near column `kunYomis`

struct Kanji: Realmable {
  var id: Int = 0
  var kanjiCharacter: String = ""
  var hexUnicode: String = ""
  var frequency: Int = 0
  var jlptLevel: Int = 0
  var gradeJA: Int = 0
  var strokeCount:Int = 0
  var classification: String = ""
  var kunYomis = [String]()
  var onYomis = [String]()
  var longMeanings = [String]()
  var shortMeanings = [String]()
  var radicalComponentCount: Int = 0
  var radicalComponentStrings = [String]()
  static func primaryKey() -> String?
  {
    return "id"
  }

}

This is the definition of the database as shown by RealmStudio when generating Swift model definition

class RLMKanji: Object {
    @objc dynamic var id: Int = 0
    @objc dynamic var kanjiCharacter: String = ""
    @objc dynamic var hexUnicode: String = ""
    @objc dynamic var frequency: Int = 0
    @objc dynamic var jlptLevel: Int = 0
    @objc dynamic var gradeJA: Int = 0
    @objc dynamic var strokeCount: Int = 0
    @objc dynamic var classification: String = ""
    let kunYomis = List<String>()
    let onYomis = List<String>()
    let longMeanings = List<String>()
    let shortMeanings = List<String>()
    @objc dynamic var radicalComponentCount: Int = 0
    let radicalComponentStrings = List<String>()

    override static func primaryKey() -> String? {
        return "id"
    }
}

Have been at it since yesterday, couldn't figure out what could be wrong. Able to open the database with RealmStudio and all the data appears correct. I'm assuming that this is not a problem with Realm itself but in my definitions but can't figure out. There are three other objects in the database as well.

.../Library/Developer/Xcode/DerivedData/JukugoExample-dswqnefsbrxzlpehxzpaxosvetds/SourcePackages/checkouts/realm-core/src/realm/table.cpp:3050: [realm-core-5.23.8] Assertion failed: get_real_column_type(col_ndx) == col_type_String || get_real_column_type(col_ndx) == col_type_StringEnum [5, 2, 5, 3] 0 JukugoExample 0x0000000106db041f _ZN5realm4utilL18terminate_internalERNSt3118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 31 1 JukugoExample 0x0000000106db06d3 _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 243 2 JukugoExample 0x0000000106d1fac0 _ZN5realm4util9terminateIJNS_10ColumnTypeES2_S2_S2_EEEvPKcS4lDpT + 240 3 JukugoExample 0x0000000106d1f890 _ZNK5realm5Table3getINS_10StringDataEEET_mm + 320 4 JukugoExample 0x0000000106652aa5 _ZNK5realm5Table10get_stringEmm + 37 5 JukugoExample 0x000000010665fc38 _ZZN12_GLOBALN_120copy_property_valuesERKN5realm8PropertyERNS0_5TableEENK3$_0clIMS4_KFNS0_10StringDataEmmEMS4_FvmmS8_bEEEDaTT0 + 408 6 JukugoExample 0x000000010665efa5 _ZN12_GLOBALN_120copy_property_valuesERKN5realm8PropertyERNS0_5TableE + 501 7 JukugoExample 0x0000000106656f14 _ZN12_GLOBALN_122make_property_optionalERN5realm5GroupERNS0_5TableENS0_8PropertyE + 84 8 JukugoExample 0x000000010665dbd0 _ZZL27apply_pre_migration_changesRN5realm5GroupERKNSt316vectorINS_12SchemaChangeENS2_9allocatorIS4_EEEEEN7ApplierclENS_13schema_change20MakePropertyNullableE + 112 9 JukugoExample 0x000000010665d89f _ZNK5realm12SchemaChange5visitIRZL27apply_pre_migration_changesRNS_5GroupERKNSt316vectorIS0_NS4_9allocatorIS0EEEEE7ApplierEEDaOT + 367 10 JukugoExample 0x0000000106654bc3 _ZL27apply_pre_migration_changesRN5realm5GroupERKNSt316vectorINS_12SchemaChangeENS2_9allocatorIS4_EEEE + 115 11 JukugoExample 0x0000000106654322 _ZN5realm11ObjectStore20apply_schema_changesERNS_5GroupEyRNS_6SchemaEyNS_10SchemaModeERKNSt3__16vectorINS_12SchemaChangeENS6_9allocatorIS8_EEEENS_4util8OptionalINS6_12basic_stringIcNS6_11char_traitsIcEENS9_IcEEEEEENS6_8functionIFvvEEE + 626 12 JukugoExample 0x000000010668f679 _ZN5realm5Realm13update_schemaENS_6SchemaEyNSt318functionIFvNS2_10shared_ptrIS0_EES5_RS1_EEENS3_IFvS5_EEEb + 1385 13 JukugoExample 0x00000001067d61fd +[RLMRealm realmWithConfiguration:error:] + 3469 14 JukugoExample 0x0000000106e02ce0 $sSo8RLMRealmC13configurationABSo0A13ConfigurationC_tKcfCTO + 144 15 JukugoExample 0x0000000106e02ede $s10RealmSwift0A0V13configurationA2C13ConfigurationVtKcfC + 94 16 JukugoExample 0x00000001065590ef $s13JukugoExample11AppDelegateC18initializeDatabaseyyF10RealmSwift0G0VyXEfU0 + 63 17 JukugoExample 0x000000010655899a $s13JukugoExample11AppDelegateC18initializeDatabaseyyF + 1114 18 JukugoExample 0x0000000106557ef7 $s13JukugoExample11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0k6LaunchJ3KeyaypGSgtF + 103 19 JukugoExample 0x0000000106557fe3 $s13JukugoExample11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0k6LaunchJ3KeyaypGSgtFTo + 211 20 UIKitCore 0x00007fff48c0fecc -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 232 21 UIKitCore 0x00007fff48c1186b -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3985 22 UIKitCore 0x00007fff48c1742d -[UIApplication _runWithMainScene:transitionContext:completion:] + 1226 23 UIKitCore 0x00007fff48322a9a -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 179 24 UIKitCore 0x00007fff48c1391b -[UIApplication _compellApplicationLaunchToCompleteUnconditionally] + 59 25 UIKitCore 0x00007fff48c13c1a -[UIApplication _run] + 754 26 UIKitCore 0x00007fff48c19220 UIApplicationMain + 1605 27 JukugoExample 0x000000010655a0fb main + 75 28 libdyld.dylib 0x00007fff519b910d start + 1 29 ??? 0x0000000000000001 0x0 + 1!!! IMPORTANT: Please send this log and info about Realm SDK version and other relevant reproduction info to help@realm.io.2020-05-17 15:46:54.297867+0530 JukugoExample[6741:129825] .../Library/Developer/Xcode/DerivedData/JukugoExample-dswqnefsbrxzlpehxzpaxosvetds/SourcePackages/checkouts/realm-core/src/realm/table.cpp:3050: [realm-core-5.23.8] Assertion failed: get_real_column_type(col_ndx) == col_type_String || get_real_column_type(col_ndx) == col_type_StringEnum [5, 2, 5, 3] 0 JukugoExample 0x0000000106db041f _ZN5realm4utilL18terminate_internalERNSt3118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 31 1 JukugoExample 0x0000000106db06d3 _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 243 2 JukugoExample 0x0000000106d1fac0 _ZN5realm4util9terminateIJNS_10ColumnTypeES2_S2_S2_EEEvPKcS4lDpT + 240 3 JukugoExample 0x0000000106d1f890 _ZNK5realm5Table3getINS_10StringDataEEET_mm + 320 4 JukugoExample 0x0000000106652aa5 _ZNK5realm5Table10get_stringEmm + 37 5 JukugoExample 0x000000010665fc38 _ZZN12_GLOBALN_120copy_property_valuesERKN5realm8PropertyERNS0_5TableEENK3$_0clIMS4_KFNS0_10StringDataEmmEMS4_FvmmS8_bEEEDaTT0 + 408 6 JukugoExample 0x000000010665efa5 _ZN12_GLOBALN_120copy_property_valuesERKN5realm8PropertyERNS0_5TableE + 501 7 JukugoExample 0x0000000106656f14 _ZN12_GLOBALN_122make_property_optionalERN5realm5GroupERNS0_5TableENS0_8PropertyE + 84 8 JukugoExample 0x000000010665dbd0 _ZZL27apply_pre_migration_changesRN5realm5GroupERKNSt316vectorINS_12SchemaChangeENS2_9allocatorIS4_EEEEEN7ApplierclENS_13schema_change20MakePropertyNullableE + 112 9 JukugoExample 0x000000010665d89f _ZNK5realm12SchemaChange5visitIRZL27apply_pre_migration_changesRNS_5GroupERKNSt316vectorIS0_NS4_9allocatorIS0EEEEE7ApplierEEDaOT + 367 10 JukugoExample 0x0000000106654bc3 _ZL27apply_pre_migration_changesRN5realm5GroupERKNSt316vectorINS_12SchemaChangeENS2_9allocatorIS4_EEEE + 115 11 JukugoExample 0x0000000106654322 _ZN5realm11ObjectStore20apply_schema_changesERNS_5GroupEyRNS_6SchemaEyNS_10SchemaModeERKNSt3__16vectorINS_12SchemaChangeENS6_9allocatorIS8_EEEENS_4util8OptionalINS6_12basic_stringIcNS6_11char_traitsIcEENS9_IcEEEEEENS6_8functionIFvvEEE + 626 12 JukugoExample 0x000000010668f679 _ZN5realm5Realm13update_schemaENS_6SchemaEyNSt318functionIFvNS2_10shared_ptrIS0_EES5_RS1_EEENS3_IFvS5_EEEb + 1385 13 JukugoExample 0x00000001067d61fd +[RLMRealm realmWithConfiguration:error:] + 3469 14 JukugoExample 0x0000000106e02ce0 $sSo8RLMRealmC13configurationABSo0A13ConfigurationC_tKcfCTO + 144 15 JukugoExample 0x0000000106e02ede $s10RealmSwift0A0V13configurationA2C13ConfigurationVtKcfC + 94 16 JukugoExample 0x00000001065590ef $s13JukugoExample11AppDelegateC18initializeDatabaseyyF10RealmSwift0G0VyXEfU0 + 63 17 JukugoExample 0x000000010655899a $s13JukugoExample11AppDelegateC18initializeDatabaseyyF + 1114 18 JukugoExample 0x0000000106557ef7 $s13JukugoExample11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0k6LaunchJ3KeyaypGSgtF + 103 19 JukugoExample 0x0000000106557fe3 $s13JukugoExample11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0k6LaunchJ3KeyaypGSgtFTo + 211 20 UIKitCore 0x00007fff48c0fecc -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 232 21 UIKitCore 0x00007fff48c1186b -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3985 22 UIKitCore 0x00007fff48c1742d -[UIApplication _runWithMainScene:transitionContext:completion:] + 1226 23 UIKitCore 0x00007fff48322a9a -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 179 24 UIKitCore 0x00007fff48c1391b -[UIApplication _compellApplicationLaunchToCompleteUnconditionally] + 59 25 UIKitCore 0x00007fff48c13c1a -[UIApplication _run] + 754 26 UIKitCore 0x00007fff48c19220 UIApplicationMain + 1605 27 JukugoExample 0x000000010655a0fb main + 75 28 libdyld.dylib 0x00007fff519b910d start + 1 29 ??? 0x0000000000000001 0x0 + 1!!! IMPORTANT: Please send this log and info about Realm SDK version and other relevant reproduction info to help@realm.io. (lldb) Screenshot 2020-05-17 at 15 58 34

arturdev commented 4 years ago

Can you try to give it an explicit type?

var kunYomis: [String] = []
var onYomis: [String] = []
var longMeanings: [String] = []
var shortMeanings: [String] = []
var radicalComponentStrings: [String] = []
lingolab2 commented 4 years ago

unfortunately, no positive impact.

On 17 May 2020, at 20:37, Artur Mkrtchyan notifications@github.com wrote:

Can you try to give it an explicit type?

var kunYomis: [String] = [] var onYomis: [String] = [] var longMeanings: [String] = [] var shortMeanings: [String] = [] var radicalComponentStrings: [String] = [] — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arturdev/Unrealm/issues/32#issuecomment-629812951, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBLCK4U4TEVIF6ULVT6LCLRR74TRANCNFSM4NDKJVBQ.

lingolab2 commented 4 years ago

Get similar crash even working with another object RLM_Kotowaza with an array. The problem is therefore not specific to RLMKanji.

lingolab2 commented 4 years ago

Don't know if this is really a Realm issue, Unrealm issue or a combination. Have instead decided to use a different approach using a Persistable protocol (https://gist.github.com/gonzalezreal/9d297c68435b9ee12bb1b009afd41d9a) instead of Unrealm.

arturdev commented 4 years ago

Could you please send me an example project where can reproduce the crash?

lingolab2 commented 4 years ago

Can I send it via direct email?

On 18-May-2020, at 16:24, Artur Mkrtchyan notifications@github.com wrote:

 Could you please send me an example project where can reproduce the crash?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

arturdev commented 4 years ago

Sure. Thanks!