-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Conversation
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 ```
There was a problem hiding this 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); |
There was a problem hiding this comment.
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)
@riversand963 has updated the pull request. Re-import the pull request |
There was a problem hiding this 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.
@riversand963 merged this pull request in b11a8b1. |
Summary:
As title. After allocating a memory buffer, initialize its content to 0s.
This fixes valgrind issue introduced in #6709.
Test Plan: