Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upFix memory corruption in `writeCopyTo`. #2020
Conversation
realm-ci
assigned
mandrigin
Sep 12, 2018
mandrigin
force-pushed the
mandrigin:bugfix/write-copy-to
branch
3 times, most recently
from
badc1cb
to
436734a
Sep 12, 2018
rasom
referenced this pull request
Sep 12, 2018
Merged
[#5180] Encrypt account's db with password #5757
This comment has been minimized.
This comment has been minimized.
@mandrigin Thanks for the fix. It looks good to me. I believe that you have fixed #1748 for us! I remember that Can you update |
kneth
added
the
T:Bug
label
Sep 13, 2018
kneth
reviewed
Sep 13, 2018
|
mandrigin
force-pushed the
mandrigin:bugfix/write-copy-to
branch
from
436734a
to
dd7b76f
Sep 13, 2018
This comment has been minimized.
This comment has been minimized.
@kneth cool, happy to help! |
kneth
merged commit 67dccf1
into
realm:master
Sep 13, 2018
This comment has been minimized.
This comment has been minimized.
@kneth yay! kudos for such swift responses! |
mandrigin
deleted the
mandrigin:bugfix/write-copy-to
branch
Sep 13, 2018
mandrigin
referenced this pull request
Sep 13, 2018
Closed
Update `realm-js` to the next released version and remove our patch for fixing encryption #5827
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
mandrigin commentedSep 12, 2018
•
edited
What, How & Why?
We found an issue that it isn't possible to open a realm database if it was created as a copy using
writeCopyTo
and providing an encryption key.The error looked like that:
After investigation, we noticed a memory corruption in the key, when it was sent to
write_copy
.Gotcha: this was only reproducible on iOS 10+ and Android, tests on macos always passed. Probably iOS 8 and 9 and macos have more relaxed memory optimizations.
After a closer look, it seems like this code was responsible for that (my comments):
I restructured the code a little bit and this bug doesn't appear anymore.
Steps to verify the problem
tests/js/realm-tests.js
with the version from this PR (required to work well on a mobile device).scripts/test.sh
to run on a modern iOS (I hardcodedIOS_RUNTIME='com.apple.CoreSimulator.SimRuntime.iOS-11-0'
locally)pushd tests/react-test-app && rm -rf node_modules && npm install && popd
scripts/test.sh react-tests
Expected:
testWriteCopyTo
fails with something likeInvalid mnemonic. top_ref[0]: 528EB59E00000001, top_ref[1]: E008049A66C646D4, mnemonic: D1 77 E4 5C, fmt[0]: 64, fmt[1]: 63, flags: F4.
Steps to verify the solution
scripts/test.sh
to run on a modern iOS (I hardcodedIOS_RUNTIME='com.apple.CoreSimulator.SimRuntime.iOS-11-0'
locally)pushd tests/react-test-app && rm -rf node_modules && npm install && popd
scripts/test.sh react-tests
Expected:
testWriteCopyTo
should pass successfully.