-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Allow error handling when realm is accessed with the wrong encryption key #1750
Comments
@issue2k I've looked through the relevant Realm code paths, and I'm not quite sure how you'd ever be getting that C++ exception. Additionally, there shouldn't be any difference handling exceptions between 32 and 64-bit devices, so something strange is going on. Would it be possible to share a bit more context around the failure? A project that reproduces it would be preferable, but even a complete stack trace would be a great help. As always, if you want to keep things private, you can send them to help@realm.io. Thanks! |
@segiddins thanks for your reply. I expect that i run into that: On the other hand, an Objective-C catch clause taking a dynamically typed exception object (@catch(id exception)) can catch any Objective-C exception, but cannot catch any C++ exceptions. So, for interoperability, use @catch(...) to catch every exception and @throw; to rethrow caught exceptions. In 32-bit, @catch(...) has the same effect as @catch(id exception). If i understand the last sentence correctly its not possible to handle C++ exceptions in Objective-C on 32bit platforms. After posting the issue i realized that the problem only occurs on Simulators < iPhone 5s. I will send an example project to you. |
@issue2k an example project would be incredibly helpful, as you shouldn't be getting any C++ exceptions from the core library -- those should be caught by realm, and then, if necessary, mapped to ObjC exceptions. |
@segiddins it took me a while to reproduce this inside of an example project. It only happens under very special conditions. What i can say now is that the crash only happens when i have included the pod CrashlyticsFramework, without Crashlytics everything is fine. It even only crashes on Simulator <= iPhone 5. It does NOT crash on a real device <= iPhone 5 (tested with iPhone 4s only). Find my example project here: https://github.com/issue2k/realm-encryption-test To reproduce the issue do the following:
|
@issue2k thanks so much for digging into this! I'll be sure to take a look at that example project, and see if there's anything we can do to improve that experience in the simulator. |
@issue2k I just cloned that project and ran it in both the iPhone 4S and iPhone 5 iOS 8.2 simulators, and did not see any crash. |
@segiddins I am using 8.3, will check 8.2 as soon as possible |
I can confirm that this only happens on iOS 8.3 Simulators <= iPhone 5. Validated this on 8.2 and 8.3 with two different computers now.
|
See http://stackoverflow.com/questions/21150223/ld-warning-too-many-personality-routines-for-compact-unwind-to-encode and https://devforums.apple.com/thread/267548?tstart=0. It looks like no one has found a workaround, but I'm going to try to rebuilding everything with xcode 6.3 to see if that helps (the current core release was built with an older version of clang). |
Rebuilding core with Xcode 6.3 doesn't eliminate the warning, so I don't think there's anything we can do. |
Closing as this is a limitation inherent to iOS and cannot be avoided outright. Please see @tgoyne's previous links for potential workarounds. |
Currently the realmWithPath method indicates that there is some error handling possible. I would expect that when accessing a realm with wrong encryption key, it just gives an error. Instead its throwing an exception which causes a crash of the app. As i am not able to handle C++ exceptions on 32bit devices (And i want to avoid handling the control flow by catching exceptions) it would be helpful if realm would not throw an exception and give a useful error message and a uniqe code to be able to handle it.
This is what i am trying to do:
[RLMRealm realmWithPath:RLMRealm.defaultRealmPath encryptionKey:key readOnly:NO error:&error]
on 64bit devices i am able to handle the thrown C++ exceptions. On 32bit devices there seems to be no way:
libc++abi.dylib: terminating with uncaught exception of type tightdb::util::DecryptionFailed: Decryption failed
Any change or other idea how i could handle this case without crashing on 32 bit devices?
The text was updated successfully, but these errors were encountered: