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

work around a TSAN report during multiprocess encryption #7143

Closed
wants to merge 1 commit into from

Conversation

ironage
Copy link
Contributor

@ironage ironage commented Nov 15, 2023

Potential fix for #6474
I think this is a better approach than adding more suppressions to TSAN because that may hide legitimate issues in the future. The cost of this approach is a performance hit when running with TSAN enabled.

@ironage ironage self-assigned this Nov 15, 2023
Copy link

coveralls-official bot commented Nov 15, 2023

Pull Request Test Coverage Report for Build james.stone_421

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • 79 unchanged lines in 10 files lost coverage.
  • Overall coverage increased (+0.02%) to 91.689%

Files with Coverage Reduction New Missed Lines %
src/realm/index_string.cpp 1 87.81%
src/realm/sync/network/network.cpp 1 90.07%
test/test_query2.cpp 1 99.08%
src/realm/obj.cpp 2 91.75%
src/realm/object-store/sync/sync_manager.cpp 2 86.96%
src/realm/util/file.cpp 2 81.69%
src/realm/uuid.cpp 2 97.06%
src/realm/sync/noinst/client_impl_base.cpp 5 85.29%
src/realm/bplustree.cpp 7 75.72%
test/fuzz_group.cpp 56 46.33%
Totals Coverage Status
Change from base Build 1838: 0.02%
Covered Lines: 231168
Relevant Lines: 252123

💛 - Coveralls

@ironage ironage marked this pull request as draft November 15, 2023 19:19
// Copying an entire page may overwrite arrays which is being read concurrently by
// another thread. This is benign because it overwrites data from old version with
// the same value as is already there, so the reader sees the correct value. This
// is all by design. However, when doing a memcpy of the entire page, TSAN sees
Copy link
Contributor

Choose a reason for hiding this comment

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

So, do you essentially think that this is just false positive? Which part is "all by design"? The obvious question from my side is why it tries to overwrite with exactly the same data :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kiburtse only some of the data on the page is expected to change when advancing versions. The parts of the page that are populated with array data for readers of older versions will not actually change, but the parts of the page that were "free space" may now be allocated and filled with new data by an external writer. TSAN says that the memcpy triggers a "write" on the old version data, even if the values didn't change. I was attempting to fix that by only copying the changed bytes, but this strategy doesn't appear to work because we still have to read the entire page to do this, which triggers another separate TSAN race (also possibly a false positive). I'm not sure this strategy is worth pursuing anymore, but I am hesitant to just add a tsan suppression because it may mask real problems.

// this as a race even though we are replacing concurrently read data with the same
// values.
for (size_t i = 0; i < num_bytes; ++i) {
if (src[i] != dst[i]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why check here if it should be the same data? Isn't this a contradiction to what is written in the comment?

@kiburtse
Copy link
Contributor

Still the same tsan warnings from ubuntu2004-encryption-tsan builder

@ironage ironage closed this Nov 25, 2023
@ironage ironage deleted the js/tsan-fpositives branch November 25, 2023 00:54
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants