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

RCORE-2108 Avoid deleting self if the instance of the same object is added to a collection in a mixed. #7647

Closed

Conversation

nicola-cab
Copy link
Member

@nicola-cab nicola-cab commented Apr 29, 2024

What, How & Why?

We should not allow this behaviour, probably the right fix is to throw an exception if we add a link to an object that is basically an instance of the same table, if the table has just one mixed column.

The aim is to prevent this issue: #7657

☑️ ToDos

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

for (auto& obj : objs)
CHECK(obj.get_backlink_count() == 1);

for (auto& obj : objs)
Copy link
Member Author

Choose a reason for hiding this comment

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

this fails:

Assertion failed: begin <= end [2, 1]
0   realm-tests                         0x000000010bd8d159

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't get this to fail.

…ollection created from the same table and colkey
@nicola-cab nicola-cab changed the title test adding a link to the same mixed Avoid deleting self if the instance of the same object is added to a collection in a mixed. Apr 30, 2024
@nicola-cab nicola-cab marked this pull request as ready for review April 30, 2024 20:42
Copy link

Pull Request Test Coverage Report for Build nicola.cabiddu_1676

Details

  • 32 of 32 (100.0%) changed or added relevant lines in 2 files are covered.
  • 50 unchanged lines in 9 files lost coverage.
  • Overall coverage increased (+0.004%) to 90.744%

Files with Coverage Reduction New Missed Lines %
src/realm/index_string.hpp 1 93.48%
src/realm/query_expression.hpp 1 93.81%
test/fuzz_tester.hpp 1 57.73%
test/test_dictionary.cpp 1 99.82%
src/realm/array_blobs_big.cpp 2 98.58%
src/realm/sync/transform.cpp 4 60.86%
src/realm/bplustree.cpp 7 72.39%
src/realm/index_string.cpp 8 84.63%
test/fuzz_group.cpp 25 47.69%
Totals Coverage Status
Change from base Build 2272: 0.004%
Covered Lines: 212498
Relevant Lines: 234172

💛 - Coveralls

@nicola-cab nicola-cab changed the title Avoid deleting self if the instance of the same object is added to a collection in a mixed. RCORE-2108 Avoid deleting self if the instance of the same object is added to a collection in a mixed. May 1, 2024
@nicola-cab nicola-cab marked this pull request as draft May 1, 2024 23:05
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.

See my comments. And I am pretty sure that this has nothing to do with the linked issue.

// Update size (also in header)
--m_size;
set_header_size(m_size);
if (ndx < size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say it is an error in the calling code if ndx is not smaller than size.

@@ -969,6 +969,40 @@ TEST(List_NestedCollection_Unresolved)
CHECK_EQUAL(list.get(0), Mixed(obj.get_link()));
}

TEST(Collection_Mixed_avoid_deleting_self)
Copy link
Contributor

Choose a reason for hiding this comment

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

The code above is not called when this test is run.

for (auto& obj : objs)
CHECK(obj.get_backlink_count() == 1);

for (auto& obj : objs)
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't get this to fail.

@nicola-cab nicola-cab closed this May 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 20, 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.

2 participants