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

Unable to initialize Realm - Invalid mnemonic #6061

Closed
jasper-chan opened this issue Jan 11, 2019 · 17 comments
Closed

Unable to initialize Realm - Invalid mnemonic #6061

jasper-chan opened this issue Jan 11, 2019 · 17 comments

Comments

@jasper-chan
Copy link

Bugs: When trying to instantiate a DefaultRealm object, an exception occurs.

Goals

Instantiate a DefaultRealm successfully

Expected Results

Instantiate a DefaultRealm successfully

Actual Results

Exception with the stack trace

/var/mobile/Containers/Data/Application/DC37B002-A218-4074-9318-7142CB94BCE3/Documents/9937ECCF-85C5-43DD-BAE2-5A4DFFC61F4D/SceneDoc.realm: Unable to open a realm at path '/var/mobile/Containers/Data/Application/DC37B002-A218-4074-9318-7142CB94BCE3/Documents/9937ECCF-85C5-43DD-BAE2-5A4DFFC61F4D/SceneDoc.realm': Invalid mnemonic. top_ref[0]: D159356A000052FC, top_ref[1]: D6E09A922D56CF5A, mnemonic: 7F 5D 15 34, fmt[0]: 207, fmt[1]: 87, flags: FF.
(
0 CoreFoundation 0x000000018236eda4 + 252
1 libobjc.A.dylib 0x00000001815285ec objc_exception_throw + 56
2 Realm 0x0000000108b431a8 Z18RLMSetErrorOrThrowP7NSErrorPU15__autoreleasingS0 + 512
3 Realm 0x0000000108b1a54c _Z26RLMRealmTranslateExceptionPU15__autoreleasingP7NSError + 120
4 Realm 0x0000000108b1b8d4 _ZL33translateSharedGroupOpenExceptionP21RLMRealmConfigurationPU15__autoreleasingP7NSError + 512
5 Realm 0x0000000108b1b65c +[RLMRealm realmWithConfiguration:error:] + 2776
6 Realm 0x0000000108b19a60 +[RLMRealm defaultRealm] + 76
7 SceneDoc 0x0000000104c1cfc4 +[RealmController initRealm] + 380
8 SceneDoc 0x0000000104c1ce30 +[RealmController sharedInstance] + 56
9 SceneDoc 0x0000000104cb3658 -[LoginVC handleLoginSuccess] + 1436
10 SceneDoc 0x0000000104cb2f1c __32-[LoginVC loginCredentialsDone:]_block_invoke + 68
11 SceneDoc 0x000000010528f718 -[SDCBaseGCD performMainThreadCallSync:] + 104
12 SceneDoc 0x0000000104bc5754 -[SDCUserServiceGCDCall getAuthenticationToken:password:] + 3012
13 SceneDoc 0x0000000104e05798 __81-[SDCThriftGCDManager getAuthenticationToken:password:successBlock:failureBlock:]_block_invoke + 56
14 SceneDoc 0x000000010550e6b4 __NR__dispatch_after_block_invoke + 76
15 libdispatch.dylib 0x000000010914119c _dispatch_client_callout + 16
16 libdispatch.dylib 0x000000010914e454 _dispatch_continuation_pop + 588
17 libdispatch.dylib 0x0000000109142e64 _dispatch_source_invoke + 1368
18 libdispatch.dylib 0x0000000109145b6c _dispatch_main_queue_callback_4CF + 732
19 CoreFoundation 0x0000000182317070 + 12
20 CoreFoundation 0x0000000182314bc8 + 2272
21 CoreFoundation 0x0000000182234da8 CFRunLoopRunSpecific + 552
22 GraphicsServices 0x000000018421a020 GSEventRunModal + 100
23 UIKit 0x000000018c254758 UIApplicationMain + 236
24 SceneDoc 0x0000000104bdd838 main + 128
25 libdyld.dylib 0x0000000181cc5fc0 + 4
)

Steps to Reproduce

Not sure what causes it to happen, but right after we set the defaultConfiguration, if we call defaultRealm, the exception will occur.

Code Sample

N/A

Version of Realm and Tooling

Realm framework version: 3.7.6
Realm Object Server version: N/A
Xcode version: 10.1
iOS/OSX version: 10.14.2

@jasper-chan
Copy link
Author

Following tickets seem to be related:

#6047
#5896
realm/realm-core#3134
realm/realm-java#6257

@jasper-chan
Copy link
Author

Can we get some kind've response for this issue? We are noticing this is happening to more and more of our users. The only remedy at the moment is to simply delete our application and re-install it. This can be very problematic for us as users may have critical business information on the device that has not synced up to our servers yet.

@tgoyne
Copy link
Member

tgoyne commented Jan 18, 2019

All that error indicates is that the thing being opened isn't a Realm file; there's a field in the header of the file that should always contain the string "T-DB" and it doesn't.

@jasper-chan
Copy link
Author

jasper-chan commented Jan 18, 2019

All that error indicates is that the thing being opened isn't a Realm file; there's a field in the header of the file that should always contain the string "T-DB" and it doesn't.

@tgoyne
Thanks for your response. That is very perplexing then as in this case, it was working a minute ago and all of a sudden, it stopped working. What should our next steps be to help understand what went wrong, and what can be done to fix this?

@jasper-chan
Copy link
Author

@tgoyne
I was wondering if there is an update regarding next steps to solving this problem? Right now, our only solution is to tell customers to delete the app and re-install, which can be a huge problem if any data is not synced up to our server. Thanks for your assistance

@tgoyne
Copy link
Member

tgoyne commented Jan 29, 2019

I don't really know what advice I can give. Your app is doing something which leads to it having something that isn't a Realm file at the path where a Realm file should be, so you'll need to track down what in your app is causing this to happen. There's not much in Realm itself that could cause this other than trying to open an encrypted realm without providing a key or a currently unknown bug.

@jasper-chan
Copy link
Author

Hi @tgoyne

I have the actual physical realm file if that is of use? All I know we do is we set the RLMRealmConfiguration, and we compact quite often.

@jasper-chan
Copy link
Author

jasper-chan commented Feb 5, 2019

Hi @tgoyne

I tried opening the Realm file in question using Realm Browser (v3.0.1) expecting it to fail, but I was able to open it. Is this expected behaviour?

@jasper-chan
Copy link
Author

Hi @tgoyne

Is there an update to my last finding?

@tgoyne
Copy link
Member

tgoyne commented Feb 8, 2019

If you can open an unencrypted realm file in the browser but it gives the invalid mnemonic error when trying to open it from ios then you are probably not actually opening the same file.

@jasper-chan
Copy link
Author

jasper-chan commented Feb 8, 2019 via email

@tgoyne
Copy link
Member

tgoyne commented Feb 8, 2019

Attempting to open an encrypted realm file without supplying an encryption key is very likely to give the invalid mnemonic error.

@jasper-chan
Copy link
Author

jasper-chan commented Feb 8, 2019 via email

@tgoyne
Copy link
Member

tgoyne commented Feb 8, 2019

Being able to open the file when supplying the key in the browser but getting the not-a-realm-file error when opening it in the app suggests that in some edge case the app is failing to supply the key when opening the realm.

If the file can be opened correctly in any cases then I have no idea what looking at the file could reveal.

@jasper-chan
Copy link
Author

jasper-chan commented Feb 9, 2019 via email

@jasper-chan
Copy link
Author

Hi @tgoyne

I am able to open the database when I hardcode the encryption key as part of the default configuration setting. Based on this testing, it would suggest your theory might be correct. In the meantime, I'd like to close out this support issue.

Thanks for your assistance.

@realm-probot
Copy link

realm-probot bot commented Mar 1, 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

3 participants