Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

fix(split): message header should not be empty struct #725

Merged
merged 1 commit into from
Jan 18, 2021
Merged
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
2 changes: 1 addition & 1 deletion src/runtime/rpc/rpc_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ message_ex *message_ex::copy_message_no_reply(const message_ex &old_msg)
static_cast<char *>(dsn::tls_trans_malloc(sizeof(message_header))),
[](char *c) { dsn::tls_trans_free(c); });
msg->header = reinterpret_cast<message_header *>(header_holder.get());
msg->header = {}; // initialize to empty struct
memset(static_cast<void *>(msg->header), 0, sizeof(message_header));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the difference between the two statements. Please write a unit-test for copy_message_no_reply

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we discuss offline, if header is an empty strtuct, it will lead problem in Line195, which is msg->header->body_length = msg->buffers[1].length();.

msg->buffers.emplace_back(blob(std::move(header_holder), sizeof(message_header)));

if (old_msg.buffers.size() == 1) {
Expand Down