Derecho-Project / derecho

The main code repository for the Derecho project.
BSD 3-Clause "New" or "Revised" License
187 stars 47 forks source link

Ordered_send computes the buffer size incorrectly #130

Closed etremel closed 5 years ago

etremel commented 5 years ago

While testing and debugging my changes for #104 and #128, I discovered another bug that seems to have existed for a while. The ordered_send function in Replicated<T> uses the function RemoteInvocableClass::get_size() to get the "size of the message" it is about to send, and it passes this value into MulticastGroup::send() as the payload_size. However, RemoteInvocableClass::get_size() actually only returns the number of bytes needed to serialize the arguments to the requested RPC function (the "payload" of the RPC message), not the number of bytes needed to serialize the entire RPC message, which includes its own "RPC header" added in RemoteInvocableClass::send(). Thus, it is incorrect for ordered_send to pass the result of RemoteInvocableClass::get_size() into MulticastGroup::send(), because that will cause MulticastGroup to use a buffer that is too small to fit the RPC message -- MulticastGroup doesn't know about the RPC headers and won't add any extra space for them. Instead, ordered_send should give MulticastGroup::send() a payload_size that includes both the RPC headers and the RPC payload (serialized arguments).