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 valgrind error by init memory region #6842

Closed
wants to merge 2 commits into from

Conversation

riversand963
Copy link
Contributor

@riversand963 riversand963 commented May 13, 2020

Summary:
As title. After allocating a memory buffer, initialize its content to 0s.
This fixes valgrind issue introduced in #6709.

Test Plan:

$make valgrind_test
$valgrind --tool=memcheck --track-origins=yes ./db_test2 --gtest_filter=DBTest2.CompressionFailures

Summary:
As title. After allocating a memory buffer, initialize its content to 0s.

Test Plan:
```
$make valgrind_test
$valgrind --tool=memcheck --log-file=valgrind.log --track-origins=yes ./db_test2 --gtest_filter=DBTest2.CompressionFailures
```
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

db/db_test2.cc Outdated
BlockContents(std::move(fake_data), contents->data.size() + 1);
const size_t len = contents->data.size() + 1;
std::unique_ptr<char[]> fake_data(new char[len]);
memset(fake_data.get(), 0, len);
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe memset can be avoided with () after new[] (https://stackoverflow.com/a/7546745/454544)

@facebook-github-bot
Copy link
Contributor

@riversand963 has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@riversand963 merged this pull request in b11a8b1.

@riversand963 riversand963 deleted the fix-valgrind branch May 15, 2020 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants