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

Fix crash caused by null embedded objects when converting local realm to sync'd realm #6295

Merged
merged 5 commits into from
Feb 21, 2023

Conversation

danieltabacaru
Copy link
Collaborator

@danieltabacaru danieltabacaru commented Feb 10, 2023

What, How & Why?

Fix crash when converting local realm to sync'd realm if an embedded object is null.
Fixes #6294, realm-js#5389

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed.

@danieltabacaru danieltabacaru marked this pull request as ready for review February 10, 2023 10:06
Copy link
Member

@nicola-cab nicola-cab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change is needed and legit.

@@ -52,6 +52,9 @@ void generate_properties_for_obj(Replication& repl, const Obj& obj, const ColInf
auto embedded_table = elem.second;
auto cols_2 = get_col_info(embedded_table);
auto update_embedded = [&](Mixed val) {
if (val.is_null()) {
Copy link
Member

@nicola-cab nicola-cab Feb 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it seems we never really cater for this use case, we have always taken for granted the fact that the link could have never been NULL, I think this is the result of how we are masking invalid links. So I think this fix is correct.

@@ -1282,7 +1288,12 @@ TEST_CASE("SharedRealm: convert") {
SECTION("can copy a synced realm to a synced realm") {
auto sync_realm1 = Realm::get_shared_realm(sync_config1);
sync_realm1->begin_transaction();
// 'embedded_link' property is null.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have added a separate test for covering this with a separate schema, but that's ok.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nicola-cab
Copy link
Member

LGTM

Copy link
Contributor

@jedelbo jedelbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@danieltabacaru danieltabacaru merged commit db62914 into master Feb 21, 2023
@danieltabacaru danieltabacaru deleted the dt/convert_fails_for_null_embedded_objects branch February 21, 2023 11:59
@kiburtse kiburtse mentioned this pull request Mar 3, 2023
3 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when converting local realm to sync'd realm if an embedded object is null
3 participants