{"action":"opened","issue":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/3544","repository_url":"https://api.github.com/repos/realm/realm-cocoa","labels_url":"https://api.github.com/repos/realm/realm-cocoa/issues/3544/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/issues/3544/comments","events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/3544/events","html_url":"https://github.com/realm/realm-cocoa/issues/3544","id":153964430,"number":3544,"title":"Migration in release configuration (Appstore) always crashes","user":{"login":"Voley","id":705508,"avatar_url":"https://avatars.githubusercontent.com/u/705508?v=3","gravatar_id":"","url":"https://api.github.com/users/Voley","html_url":"https://github.com/Voley","followers_url":"https://api.github.com/users/Voley/followers","following_url":"https://api.github.com/users/Voley/following{/other_user}","gists_url":"https://api.github.com/users/Voley/gists{/gist_id}","starred_url":"https://api.github.com/users/Voley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Voley/subscriptions","organizations_url":"https://api.github.com/users/Voley/orgs","repos_url":"https://api.github.com/users/Voley/repos","events_url":"https://api.github.com/users/Voley/events{/privacy}","received_events_url":"https://api.github.com/users/Voley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-10T09:40:12Z","updated_at":"2016-05-10T09:40:12Z","closed_at":null,"body":"## Goals\r\n\r\nI want to have application that is stable and does not crash on startup after update. Crash always happens after update.\r\nI had version 1.0 of my App with 0.96 Realm, after updating I had a bug with migration - which I found via another bug report can be fixed by updating realm to latest version (0.101.0);\r\nI have updated to newest version, updated my migration code and I am getting another crash.\r\n\r\n## Expected Results\r\n\r\nI expected migration to work correctly. \r\n\r\n## Actual Results\r\n```\r\n\r\nIncident Identifier: 6685F4F8-D44D-4100-B8F8-557B274D008A\r\nCrashReporter Key:   ef721e5876606f0dbdb9a5c5d7d6b62400172f12\r\nHardware Model:      iPhone7,1\r\nProcess:             Ezbusy-iOS [3210]\r\nPath:                /private/var/containers/Bundle/Application/845DC646-1361-408F-AC73-43C271F4CE65/Ezhome-iOS.app/Ezhome-iOS\r\nIdentifier:          com.ezbusy.ezbusy\r\nVersion:             34 (1.0.1)\r\nCode Type:           ARM-64 (Native)\r\nParent Process:      launchd [1]\r\n\r\nDate/Time:           2016-05-10 11:00:39.39 +0300\r\nLaunch Time:         2016-05-10 11:00:39.39 +0300\r\nOS Version:          iOS 9.3.1 (13E238)\r\nReport Version:      105\r\n\r\nException Type:  EXC_CRASH (SIGABRT)\r\nException Codes: 0x0000000000000000, 0x0000000000000000\r\nException Note:  EXC_CORPSE_NOTIFY\r\nTriggered by Thread:  0\r\n\r\nFiltered syslog:\r\nNone found\r\n\r\nLast Exception Backtrace:\r\n0   CoreFoundation                \t0x180dbee38 __exceptionPreprocess + 124\r\n1   libobjc.A.dylib               \t0x180423f80 objc_exception_throw + 56\r\n2   Ezhome-iOS                    \t0x1002a06e4 RLMSetErrorOrThrow(NSError*, NSError* __autoreleasing*) (RLMUtil.mm:302)\r\n3   Ezhome-iOS                    \t0x10029390c +[RLMRealm openSharedRealm:error:] (RLMRealm.mm:252)\r\n4   Ezhome-iOS                    \t0x100293f04 +[RLMRealm realmWithConfiguration:error:] (RLMRealm.mm:329)\r\n5   Ezhome-iOS                    \t0x100293194 +[RLMRealm defaultRealm] (RLMRealm.mm:158)\r\n6   Ezhome-iOS                    \t0x10010cebc -[AppDelegate migrateDatabase] (AppDelegate.m:143)\r\n7   Ezhome-iOS                    \t0x10010c48c -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:28)\r\n8   UIKit                         \t0x185f7e8a8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 400\r\n9   UIKit                         \t0x1861ae094 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2904\r\n10  UIKit                         \t0x1861b2500 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1684\r\n11  UIKit                         \t0x1861af674 -[UIApplication workspaceDidEndTransaction:] + 168\r\n12  FrontBoardServices            \t0x18275f7ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36\r\n13  FrontBoardServices            \t0x18275f618 -[FBSSerialQueue _performNext] + 168\r\n14  FrontBoardServices            \t0x18275f9c8 -[FBSSerialQueue _performNextFromRunLoopSource] + 56\r\n15  CoreFoundation                \t0x180d75124 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24\r\n16  CoreFoundation                \t0x180d74bb8 __CFRunLoopDoSources0 + 540\r\n17  CoreFoundation                \t0x180d728b8 __CFRunLoopRun + 724\r\n18  CoreFoundation                \t0x180c9cd10 CFRunLoopRunSpecific + 384\r\n19  UIKit                         \t0x185f77834 -[UIApplication _run] + 460\r\n20  UIKit                         \t0x185f71f70 UIApplicationMain + 204\r\n21  Ezhome-iOS                    \t0x10014a1f0 main (main.m:14)\r\n22  libdyld.dylib                 \t0x18083a8b8 start + 4\r\n\r\n\r\n```\r\n## Steps to Reproduce\r\n\r\nNot sure about this, since it is reproducible in my environment. I perform a database migration that always crashes on calling defaultRealm in the end\r\n\r\n## Code Sample\r\n\r\nCode relevant for migration - \r\n```\r\n- (void)migrateDatabase {\r\n    \r\n    // App Versions and database versions\r\n    // 1.0 -> 0\r\n    // 1.0.1 -> 1\r\n    // 1.0.2 -> 2\r\n    \r\n    RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];\r\n    config.schemaVersion = 2;\r\n    config.migrationBlock = ^(RLMMigration *migration, uint64_t oldSchemaVersion) {\r\n        if (oldSchemaVersion < 2) {\r\n            \r\n            [migration enumerateObjects:EZHProfile.className\r\n                  block:^(RLMObject *oldObject, RLMObject *newObject) {\r\n                      // Add the 'enhancementNotifications' property only to Realms with a schema version of 2\r\n                      if (oldSchemaVersion < 2) {\r\n                          newObject[@\"enhancementNotifications\"] = nil;\r\n                      }\r\n                  }];\r\n        };\r\n    };\r\n    \r\n    // Tell Realm to use this new configuration object for the default Realm\r\n    [RLMRealmConfiguration setDefaultConfiguration:config];\r\n    \r\n    // Now that we've told Realm how to handle the schema change, opening the file\r\n    // will automatically perform the migration\r\n    [RLMRealm defaultRealm];\r\n}\r\n```\r\n\r\nFull crash log - http://pastebin.com/XN9qhmWp\r\n\r\n## Version of Realm and Tooling\r\n\r\n[In the CONTRIBUTING guidelines](https://git.io/vgxJO), you will find a script,\r\nwhich will help determining these versions.\r\n\r\nRealm version: 0.101.0\r\n\r\nXcode version: 7.3\r\nBuild version 7D175\r\n\r\niOS/OSX version: 9.3\r\nProductName:\tMac OS X\r\nProductVersion:\t10.11.4\r\nBuildVersion:\t15E65\r\n\r\nDependency manager + version: Cocoapods 0.39.0"}}