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(asan): repeated memory release in pegasus_server_write_test.batch_writes #685

Merged
merged 6 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/server/test/hotkey_collector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,14 @@ TEST_F(hotkey_collector_test, data_completeness)
resp);
ASSERT_EQ(resp.err, dsn::ERR_OK);

auto writes = new dsn::message_ex *[1000];
auto cleanup = dsn::defer([=]() {
for (int i = 0; i < 1000; i++) {
writes[i]->release_ref();
}
delete[] writes;
});
for (int i = 0; i < 1000; i++) {
const uint16_t WRITE_REQUEST_COUNT = 1000;
dsn::message_ex *writes[WRITE_REQUEST_COUNT];
for (int i = 0; i < WRITE_REQUEST_COUNT; i++) {
writes[i] = create_put_request(generate_set_req(std::to_string(i)));
}
_server->on_batched_write_requests(int64_t(0), uint64_t(0), writes, 1000);
_server->on_batched_write_requests(int64_t(0), uint64_t(0), writes, WRITE_REQUEST_COUNT);

for (int i = 0; i < 1000; i++) {
for (int i = 0; i < WRITE_REQUEST_COUNT; i++) {
auto rpc = generate_get_rpc(std::to_string(i));
_server->on_get(rpc);
auto value = rpc.response().value.to_string();
Expand Down
13 changes: 6 additions & 7 deletions src/server/test/pegasus_server_write_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,18 @@ class pegasus_server_write_test : public pegasus_server_test_base
int put_rpc_cnt = dsn::rand::next_u32(1, 10);
int remove_rpc_cnt = dsn::rand::next_u32(1, 10);
int total_rpc_cnt = put_rpc_cnt + remove_rpc_cnt;
auto writes = new dsn::message_ex *[total_rpc_cnt];
/**
* writes[0] ~ writes[total_rpc_cnt-1] will be released by their corresponding
* rpc_holders, which created in on_batched_write_requests. So we don't need to
* release them here
**/
dsn::message_ex *writes[total_rpc_cnt];
for (int i = 0; i < put_rpc_cnt; i++) {
writes[i] = pegasus::create_put_request(req);
}
for (int i = put_rpc_cnt; i < total_rpc_cnt; i++) {
writes[i] = pegasus::create_remove_request(key);
}
auto cleanup = dsn::defer([=]() {
Copy link
Contributor

@Smityz Smityz Jan 20, 2021

Choose a reason for hiding this comment

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

auto cleanup = dsn::defer([=]() {

May have the same problem, can you help to fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

for (int i = 0; i < total_rpc_cnt; i++) {
writes[i]->release_ref();
}
delete[] writes;
});

int err =
_server_write->on_batched_write_requests(writes, total_rpc_cnt, decree, 0);
Expand Down