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

Refactoring get_path() #6472

Merged
merged 1 commit into from
May 8, 2023
Merged

Refactoring get_path() #6472

merged 1 commit into from
May 8, 2023

Conversation

jedelbo
Copy link
Contributor

@jedelbo jedelbo commented Apr 5, 2023

What, How & Why?

☑️ ToDos

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

@danieltabacaru
Copy link
Collaborator

AddressSanitizer complains about a use-after-free related to using a StringData for the field name:

3: ==5410==ERROR: AddressSanitizer: heap-use-after-free on address 0x60e0001056d0 at pc 0x0000004c24a6 bp 0x7fff381fb600 sp 0x7fff381fada8 3: READ of size 13 at 0x60e0001056d0 thread T0 3: #0 0x4c24a5 in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long) crtstuff.c 3: #1 0x4c29f9 in __interceptor_bcmp (/mnt/jenkins/workspace/realm_realm-core_PR-6472@2/build-dir/test/object-store/realm-object-store-tests+0x4c29f9) 3: #2 0x522b3fe in int std::__memcmp<char, char>(char const*, char const*, unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algobase.h:105:9 3: #3 0x522b3fe in bool std::__equal<true>::equal<char>(char const*, char const*, char const*) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algobase.h:1177:14 3: #4 0x522b3fe in bool std::__equal_aux1<char const*, char const*>(char const*, char const*, char const*) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algobase.h:1211:14 3: #5 0x522b3fe in bool std::__equal_aux<char const*, char const*>(char const*, char const*, char const*) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algobase.h:1219:14 3: #6 0x522b3fe in bool std::equal<char const*, char const*>(char const*, char const*, char const*) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algobase.h:1556:14 3: #7 0x522b3fe in bool realm::safe_equal<char const*, char const*>(char const*, char const*, char const*) /mnt/jenkins/workspace/realm_realm-core_PR-6472@2/src/realm/utilities.hpp:301:12 3: #8 0x522b3fe in realm::operator==(realm::StringData const&, realm::StringData const&) /mnt/jenkins/workspace/realm_realm-core_PR-6472@2/src/realm/string_data.hpp:251:66 3: #9 0x522b3fe in realm::sync::SyncReplication::populate_path_instr(realm::sync::instr::PathInstruction&, realm::Table const&, realm::ObjKey, realm::StringData) /mnt/jenkins/workspace/realm_realm-core_PR-6472@2/src/realm/sync/instruction_replication.cpp:810:27

@jedelbo jedelbo force-pushed the je/get-path branch 3 times, most recently from 8d0566a to e9bd77a Compare April 12, 2023 14:08
@jedelbo jedelbo force-pushed the je/link-handling-nested-collections branch from 24a763b to e132c10 Compare April 14, 2023 10:55
@jedelbo jedelbo force-pushed the je/link-handling-nested-collections branch from e132c10 to df9dab4 Compare April 14, 2023 11:33
Base automatically changed from je/link-handling-nested-collections to next-major April 18, 2023 12:27
@jedelbo jedelbo marked this pull request as ready for review April 24, 2023 10:50
@jedelbo
Copy link
Contributor Author

jedelbo commented Apr 24, 2023

@danieltabacaru This PR should be ready for review now.

FullPath result;
if (m_table->is_embedded()) {
REALM_ASSERT(get_backlink_count() == 1);
m_table->for_each_backlink_column([&](ColKey col_key) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this since there is only one backlink?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There may be several backlink columns - one for each Table that points to this embedded Table

Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't we assert above that it's just 1? (or maybe get_backlink_count() does something else)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We assert that we have only one backlink. So although we have several backlink columns, only one of them must contain a link. We have to go through all to find that one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

got it

Copy link
Collaborator

@danieltabacaru danieltabacaru left a comment

Choose a reason for hiding this comment

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

LGTM

@jedelbo jedelbo merged commit 82eab59 into next-major May 8, 2023
@jedelbo jedelbo deleted the je/get-path branch May 8, 2023 07:24
@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.

None yet

2 participants