realm-swift: Operation not permitted when trying to open realm
I know some people have reported it, but I haven’t found a fix to it.
Goals
Know the reason why it happens
Expected Results
apps not crashing
Actual Results
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=2 "Unable to open a realm at path '/var/mobile/Containers/Data/Application/5CB3C733-8188-440C-9AF5-A24169CD580A/Documents/default.realm.lock': open() failed: Operation not permitted Path: /var/mobile/Containers/Data/Application/5CB3C733-8188-440C-9AF5-A24169CD580A/Documents/default.realm.lock Exception backtrace: 0 Realm 0x0000000101422ad0 _ZN5realm4util4File13open_internalERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS1_10AccessModeENS1_10CreateModeEiPb + 712 1 Realm 0x0000000101329d70 _ZN5realm11SharedGroup7do_openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbbNS_18SharedGroupOptionsE + 1272 2 Realm 0x00000001012498ac _ZN5realm5_impl11RealmFriend13read_group_toERNS_5RealmENS_9VersionIDE + 4712 3 Realm 0x0000000101249540 _ZN5realm5_impl11RealmFriend13re
Crashed: com.apple.main-thread
0 libswiftCore.dylib 0x1a120faa4 specialized _assertionFailure(_:_:file:line:flags:) + 440
1 libswiftCore.dylib 0x1a1069910 swift_unexpectedError + 288
2 our_app 0x1006b0a04 specialized AppDelegate.checkRealmSchema() + 285 (AppDelegate.swift:285)
3 our_app 0x1006aeedc AppDelegate.setupTabs() + 172 (AppDelegate.swift:172)
4 our_app 0x1006b0f84 specialized AppDelegate.application(_:didFinishLaunchingWithOptions:) + 41 (AppDelegate.swift:41)
5 our_app 0x1006ae470 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 4305511536 (<compiler-generated>:4305511536)
6 UIKitCore 0x197dceee4 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 340
7 UIKitCore 0x197dd0ca0 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 5076
8 UIKitCore 0x197dd642c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1248
9 UIKitCore 0x1975a3208 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 148
10 UIKitCore 0x197a39698 _UIScenePerformActionsWithLifecycleActionMask + 100
11 UIKitCore 0x1975a3cf0 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 196
12 UIKitCore 0x1975a37fc -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 476
13 UIKitCore 0x1975a3b1c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 736
14 UIKitCore 0x1975a33d8 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 336
15 UIKitCore 0x1975a78c4 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 + 188
16 UIKitCore 0x19796af08 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 824
17 UIKitCore 0x197a52c84 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 244
18 UIKitCore 0x1975a75fc __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 136
19 UIKitCore 0x197a52b80 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 100
20 UIKitCore 0x1975a7468 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 376
21 UIKitCore 0x1974192c0 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 636
22 UIKitCore 0x197417e28 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 248
23 UIKitCore 0x197418ff8 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220
24 UIKitCore 0x197dd47e4 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 548
25 UIKitCore 0x19798b900 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 360
26 FrontBoardServices 0x198e857a0 -[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 436
27 FrontBoardServices 0x198eaa838 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke.154 + 100
28 FrontBoardServices 0x198e8ff04 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
29 FrontBoardServices 0x198eaa4f4 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke + 312
30 libdispatch.dylib 0x193a1f184 _dispatch_client_callout + 16
31 libdispatch.dylib 0x1939f9420 _dispatch_block_invoke_direct$VARIANT$armv81 + 216
32 FrontBoardServices 0x198ecf418 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
33 FrontBoardServices 0x198ecf0e4 -[FBSSerialQueue _queue_performNextIfPossible] + 404
34 FrontBoardServices 0x198ecf60c -[FBSSerialQueue _performNextFromRunLoopSource] + 28
35 CoreFoundation 0x193cd0a00 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
36 CoreFoundation 0x193cd0958 __CFRunLoopDoSource0 + 80
37 CoreFoundation 0x193cd0140 __CFRunLoopDoSources0 + 260
38 CoreFoundation 0x193ccb23c __CFRunLoopRun + 1080
39 CoreFoundation 0x193ccaadc CFRunLoopRunSpecific + 464
40 GraphicsServices 0x19dc6b328 GSEventRunModal + 104
41 UIKitCore 0x197dd863c UIApplicationMain + 1936
42 our_app 0x10067ca2c main + 22 (MapSelectionViewController.swift:22)
43 libdyld.dylib 0x193b54360 start + 4
What is weird is, it is always crash when started from MapSelectionViewController which probably means it is not in background.
Steps to Reproduce
No clue how.
Code Sample
have been trying this with no luck.
Realm.Configuration.defaultConfiguration = config
/** Realm will crash if it can't write into files in it's directory. Try to remove permission and open again**/
do {
_ = try Realm()
} catch _ as NSError {
let realmPath = Realm.Configuration.defaultConfiguration.fileURL!.deletingLastPathComponent().path
try! FileManager.default.setAttributes([.protectionKey: FileProtectionType.none], ofItemAtPath: realmPath)
_ = try! Realm()
}
Version of Realm and Tooling
Realm framework version: 5.2.0
Realm Object Server version: ?
Xcode version: 11.3.1
iOS/OSX version: 12 and 13
Dependency manager + version: ?
Thanks before.
Edit: Firebase shows 0% background, if it helps. I don’t think it is memory problem too, since users still have some left.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 20 (5 by maintainers)
version 5.3.5 found the same crash!
Facing same issue. Please share solution over here.