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

Use typed comparisons for set algebra on strings and binary #7144

Merged
merged 2 commits into from
Nov 17, 2023

Conversation

tgoyne
Copy link
Member

@tgoyne tgoyne commented Nov 15, 2023

On platforms where char is signed, ordering StringData and Mixed containing the same strings gives different results, so we need to use the typed comparisons. This brings us up to 6 instantiations of each operation rather than 2, but it's still a lot less than the 38 we used to have.

While looking at the code I also noticed another problem: assign_intersection() cleared the set and then inserted the elements from the RHS set, which is a use-after-free if the RHS set is this.

Fixes #7135.

@tgoyne tgoyne self-assigned this Nov 15, 2023
@tgoyne tgoyne force-pushed the tg/set-fixes branch 3 times, most recently from deffbd1 to ca36ee6 Compare November 16, 2023 05:08
Copy link

coveralls-official bot commented Nov 16, 2023

Pull Request Test Coverage Report for Build github_pull_request_284769

  • 256 of 263 (97.34%) changed or added relevant lines in 4 files are covered.
  • 77 unchanged lines in 16 files lost coverage.
  • Overall coverage increased (+0.05%) to 91.712%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/realm/collection.hpp 4 7 57.14%
test/test_set.cpp 133 137 97.08%
Files with Coverage Reduction New Missed Lines %
src/realm/sync/noinst/client_impl_base.hpp 1 93.91%
test/test_query2.cpp 1 99.08%
src/realm/array_string.cpp 2 88.0%
src/realm/query_expression.hpp 2 93.51%
src/realm/sync/network/http.hpp 2 80.87%
src/realm/sync/network/websocket.cpp 2 74.23%
src/realm/table_view.cpp 2 94.18%
test/test_sync.cpp 2 94.14%
src/realm/sync/noinst/protocol_codec.hpp 3 76.21%
src/realm/util/serializer.cpp 3 90.03%
Totals Coverage Status
Change from base Build 1841: 0.05%
Covered Lines: 231343
Relevant Lines: 252249

💛 - Coveralls

After calling `clear()`, the values to be inserted in the set would no longer
be valid if the rhs was the same set and the values were StringData or
BinaryData.
On platforms where `char` is signed, ordering StringData and Mixed containing
the same strings gives different results.
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.

Nice work

@jedelbo jedelbo merged commit b0b4936 into master Nov 17, 2023
2 checks passed
@jedelbo jedelbo deleted the tg/set-fixes branch November 17, 2023 10:56
@jedelbo jedelbo mentioned this pull request Nov 17, 2023
4 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in Set::assign_difference in Core 13.23.4
2 participants