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

RLMException: primary property name on RealmSwiftPermissionRole crash when getting a realm instance #6181

Closed
bearjaw opened this issue Jun 16, 2019 · 11 comments

Comments

@bearjaw
Copy link

bearjaw commented Jun 16, 2019

Goals

Access a realm instance and add objects when the view is loaded.

Expected Results

The app should start and objects should have been added to the database.

Actual Results

The app crashes because it's unable to find the primary property name on RealmSwiftPermissionRole. This is a default class provided by the Realm framework.
It only seems to be an issue when building and running the app through the current Xcode beta.

I have encountered this issue in other apps as well.

The app itself does not use any Realm Platform related objects.
It seems to be quite a weird error considering that apps run fine on older versions of Xcode with the same RealmSwift version.

Stacktrace:

*** Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'name' does not exist on object 'RealmSwiftPermissionRole''
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010b940b6e __exceptionPreprocess + 350
	1   libobjc.A.dylib                     0x000000010820bf57 objc_exception_throw + 48
	2   Realm                               0x000000010919f1d3 +[RLMObjectSchema schemaForObjectClass:] + 4371
	3   Realm                               0x00000001092af79e _ZL16RLMRegisterClassP10objc_class + 302
	4   Realm                               0x00000001092b07cd __25+[RLMSchema sharedSchema]_block_invoke + 77
	5   CoreFoundation                      0x000000010b9c7277 __NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__ + 7
	6   CoreFoundation                      0x000000010b9a1fde -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 238
	7   Realm                               0x00000001092b050f +[RLMSchema sharedSchema] + 479
	8   Realm                               0x000000010927b2e5 +[RLMRealm realmWithConfiguration:error:] + 2805
	9   RealmSwift                          0x00000001078c64c8 $sSo8RLMRealmC13configurationABSo0A13ConfigurationC_tKcfCTO + 152
	10  RealmSwift                          0x00000001078c6380 $s10RealmSwift0A0CACyKcfC + 112
	11  RBSRealmBrowser_Example             0x000000010740ea1d $s23RBSRealmBrowser_Example14ViewControllerC9safeWrite33_5609E96CEFC5AD309B5F22C74E3BF6D0LL02inG0yy10RealmSwift0R0CXE_tF + 109
	12  RBSRealmBrowser_Example             0x000000010740e1ca $s23RBSRealmBrowser_Example14ViewControllerC11viewDidLoadyyFySSXEfU_ + 234
	13  RBSRealmBrowser_Example             0x000000010740e5d3 $sSSs5Error_pIggzo_SSsAA_pIegnzo_TR + 51
	14  RBSRealmBrowser_Example             0x000000010740e64b $sSSs5Error_pIggzo_SSsAA_pIegnzo_TRTA + 27
	15  libswiftCore.dylib                  0x00000001083fbe64 $sSTsE7forEachyyy7ElementQzKXEKF + 452
	16  RBSRealmBrowser_Example             0x000000010740de7a $s23RBSRealmBrowser_Example14ViewControllerC11viewDidLoadyyF + 746
	17  RBSRealmBrowser_Example             0x000000010740e81b $s23RBSRealmBrowser_Example14ViewControllerC11viewDidLoadyyFTo + 43
	18  UIKitCore                           0x00000001139be496 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 83
	19  UIKitCore                           0x00000001139c33b4 -[UIViewController loadViewIfRequired] + 1084
	20  UIKitCore                           0x00000001139c37d1 -[UIViewController view] + 27
	21  UIKitCore                           0x0000000113934aaf -[UINavigationController preferredContentSize] + 187
	22  UIKitCore                           0x00000001138dbf74 -[UIPresentationController preferredContentSizeDidChangeForChildContentContainer:] + 64
	23  UIKitCore                           0x00000001138d7e8c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 133
	24  UIKitCore                           0x00000001138ddec4 +[UIPresentationController _scheduleTransition:] + 79
	25  UIKitCore                           0x00000001138d7c54 -[UIPresentationController runTransitionForCurrentState] + 1509
	26  UIKitCore                           0x00000001138d5389 -[UIPresentationController _presentWithAnimationController:interactionController:target:didEndSelector:] + 1053
	27  UIKitCore                           0x0000000114055935 -[UIWindow addRootViewControllerViewIfPossible] + 391
	28  UIKitCore                           0x0000000114055f93 -[UIWindow _setHidden:forced:] + 325
	29  UIKitCore                           0x0000000114068882 -[UIWindow _mainQueue_makeKeyAndVisible] + 42
	30  RBSRealmBrowser_Example             0x0000000107411c67 $s23RBSRealmBrowser_Example11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0l6LaunchK3KeyaypGSgtF + 1943
	31  RBSRealmBrowser_Example             0x0000000107412204 $s23RBSRealmBrowser_Example11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0l6LaunchK3KeyaypGSgtFTo + 212
	32  UIKitCore                           0x0000000114015875 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 232
	33  UIKitCore                           0x000000011401720d -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3980
	34  UIKitCore                           0x000000011401c8ae -[UIApplication _runWithMainScene:transitionContext:completion:] + 1286
	35  UIKitCore                           0x0000000113789e8c -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122
	36  UIKitCore                           0x0000000113c568a0 _UIScenePerformActionsWithLifecycleActionMask + 78
	37  UIKitCore                           0x000000011378a993 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198
	38  UIKitCore                           0x000000011378a45f -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 474
	39  UIKitCore                           0x000000011378a7c3 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 810
	40  UIKitCore                           0x000000011378a060 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 345
	41  UIKitCore                           0x000000011378e3ca __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 + 159
	42  UIKitCore                           0x0000000113b8108e +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 845
	43  UIKitCore                           0x0000000113c7465c _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 240
	44  UIKitCore                           0x000000011378e009 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 171
	45  UIKitCore                           0x0000000113c7455f _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 84
	46  UIKitCore                           0x000000011378de68 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 359
	47  UIKitCore                           0x00000001135fc9b7 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 657
	48  UIKitCore                           0x00000001135fb930 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 374
	49  UIKitCore                           0x00000001135fc6e1 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 210
	50  UIKitCore                           0x000000011401b126 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 535
	51  UIKitCore                           0x0000000113ba177d -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361
	52  FrontBoardServices                  0x000000011168eb69 -[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 442
	53  FrontBoardServices                  0x00000001116b7168 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke.160 + 102
	54  FrontBoardServices                  0x0000000111699a99 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 220
	55  FrontBoardServices                  0x00000001116b6df9 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke + 355
	56  libdispatch.dylib                   0x000000010a9d5ed0 _dispatch_client_callout + 8
	57  libdispatch.dylib                   0x000000010a9d8e41 _dispatch_block_invoke_direct + 300
	58  FrontBoardServices                  0x00000001116de22b __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
	59  FrontBoardServices                  0x00000001116ddf12 -[FBSSerialQueue _performNext] + 436
	60  FrontBoardServices                  0x00000001116de433 -[FBSSerialQueue _performNextFromRunLoopSource] + 33
	61  CoreFoundation                      0x000000010b8a4371 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	62  CoreFoundation                      0x000000010b8a4301 __CFRunLoopDoSource0 + 81
	63  CoreFoundation                      0x000000010b8a3ad4 __CFRunLoopDoSources0 + 180
	64  CoreFoundation                      0x000000010b89e7ef __CFRunLoopRun + 1263
	65  CoreFoundation                      0x000000010b89dfd6 CFRunLoopRunSpecific + 438
	66  GraphicsServices                    0x00000001108dc9f8 GSEventRunModal + 65
	67  UIKitCore                           0x000000011401e722 UIApplicationMain + 1621
	68  RBSRealmBrowser_Example             0x0000000107412b5b main + 75
	69  libdyld.dylib                       0x000000010aa5e6ad start + 1
	70  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Steps to Reproduce

  1. Update RealmSwift to the latest version either the official or the Xcode beta branch one
  2. Build & run the sample app in https://github.com/bearjaw/RBSRealmBrowser
    => Immediately after the app launches it crashes with the above provided error.
    This always happens and it seems to be triggered the first time I try to a get a realm instance through try Realm().

Code Sample

A sample project can be found here https://github.com/bearjaw/RBSRealmBrowser

Version of Realm and Tooling

Realm framework version: 3.16.2
Xcode version: 11 b1
iOS/OSX version: 13.0 b1
Dependency manager + version: CocoaPods 1.7.2

@bearjaw bearjaw changed the title RLMException: primary property name on RealmSwiftPermissionRole when getting a realm instance RLMException: primary property name on RealmSwiftPermissionRole crash when getting a realm instance Jun 16, 2019
@owenzhao
Copy link

Got the same error with Xcode 11 beta 2.

@buffsldr
Copy link

Got the same error with Xcode 11 beta 2

@tgoyne
Copy link
Member

tgoyne commented Jun 21, 2019

I can't reproduce this. I cloned the repository, ran pod update in the Examples directory, then opened RBSRealmBrowser.xcworkspace. I hit Run, and then in the app tapped the Open button and was able to browse the same data without any problems. I tested on both the iPad Air simulator and an iPhone 6S running iOS 12.

@buffsldr
Copy link

@bearjaw Interesting. I got the exact error as you several times, then I ran Analysis tool in Xcode and it identified change.visit(applier); (see line 589 of object_store.cpp) as a potential issue, so I set a breakpoint on that and ran the project inspecting the first several instances of applier. I didn't learn anything so I removed the breakpoint and continued to run the app. It worked! This makes me wonder if this isn't some kind of race condition. I am curious what happens when you try this. FWIW, I am running this in simulator on a Mid 2017 macbook.

@owenzhao
Copy link

My project no longer has this issue now. The weird thing is that I didn't do anything after my prior post.

I didn't quit Xcode 11 beta 2 when I ran pod update. I got realm update available in the console though in target the version of Realm is already the latest. Maybe that is the issue.

Today I didn't get the update available notice. And the project worked.

@tgoyne
Copy link
Member

tgoyne commented Jun 21, 2019

Perhaps after you ran pod update Xcode failed to notice that the files had changed and just linked in the old library? I've seen strange issues when not doing a clean rebuild after updating pods before.

@adamofsky
Copy link

Got the same error with Xcode 11 beta 2.

@bearjaw
Copy link
Author

bearjaw commented Jun 22, 2019

I had an earlier version installed on device and simulator and in both cases the app would crash instantly. Even resetting and newly installing the app would lead to the same result.

I noticed that when I changed how I accessed Realm it wouldn’t crash.

For me it can’t be an ‘Xcode didn’t notice that the files had changed’ because a clean build would produce the same error. Even clearing the pod cache & redownloading Realm did not change the outcome.

It’s even weirder that @buffsldr couldn’t reproduce it because for me and my colleagues it happened always when building through Xcode 11.

@adamofsky
Copy link

I had this issue on Xcode 11 beta 2 iOS simulator with iOS 13.
So I tried to run the app on iOS simulator with iOS 12.1(same Xcode 11 beta 2) current error not appears.
After that, tried again iOS 13 and the error has gone, everything working properly.

@bearjaw
Copy link
Author

bearjaw commented Jul 28, 2019

Doesn't occur anymore so I assume it's been fixed. I closed the issue.

@bearjaw bearjaw closed this as completed Jul 28, 2019
@realm-probot
Copy link

realm-probot bot commented Jul 28, 2019

Hey - looks like you forgot to add a T:* label - could you please add one?

@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

5 participants