-
Notifications
You must be signed in to change notification settings - Fork 312
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(asan): heap-use-after-free in pegasus_write_service.cpp #478
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Good work! But I prefer to have the variables in the local scope. Because it's hard to explain what put_rpc put;
remove_rpc remove;
if (request.task_code == dsn::apps::RPC_RRDB_RRDB_PUT) {
put = put_rpc(put);
err = _impl->batch_put(ctx, put.request(), put.response());
}
if (request.task_code == dsn::apps::RPC_RRDB_RRDB_REMOVE) {
remove = remove_rpc(write);
err = _impl->batch_remove(ctx.decree, remove.request(), remove.response());
}
if (!err) {
err = _impl->batch_commit(ctx.decree);
} else {
_impl->batch_abort(ctx.decree, err);
}
resp.__set_error(err);
return resp.error; |
… duplicate_huaf_bug
Ok, It's better! |
levy5307
reviewed
Feb 19, 2020
foreverneverer
force-pushed
the
duplicate_huaf_bug
branch
from
February 19, 2020 09:30
ec59a0c
to
7289c63
Compare
neverchanje
approved these changes
Feb 19, 2020
hycdong
approved these changes
Feb 19, 2020
Closed
neverchanje
pushed a commit
that referenced
this pull request
Mar 31, 2020
acelyc111
pushed a commit
that referenced
this pull request
Jun 23, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
It reports
heap-use-after-free
bug when excuting the unittestpegasus_write_service_test.duplicate_batched
(build with sanitizer). The reason is thaterr = _impl->batch_commit(ctx.decree)
(line 312 ) still use the member of the local variableput_rpc
afterput_rpc
freed(line 304).https://github.com/XiaoMi/pegasus/blob/695b366dc8605d4b27b9ff6800f2ff066ca56419/src/server/pegasus_write_service.cpp#L300-L321
Coredump
What is changed and how it works?
Same to the code:
https://github.com/XiaoMi/pegasus/blob/695b366dc8605d4b27b9ff6800f2ff066ca56419/src/server/pegasus_server_write.cpp#L89-L124
add
_put_rpc_batch.emplace_back(std::move(rpc))
(line 93) and_put_rpc_batch.clear()
(line 122) after it no longer needed.Related changes