Currently in sender side, a Message is serialized to std::string and convert to a char array (size is equal to string size + 1). Then it is referred to a iovec inside a msghdr.
In receiver side, the iovec is extracted to a 4*4096 char array. Then this char array feed into ParseFromString to generate the original Message object.
This works when the original string contains no '\0' between [0:size()-1]. However, proto2 may encode the serialized string with '\0' in the middle. In this case (I modified ipc.proto to support unmount and this happens, hard to debug...), the length parameter fed into ParseFromArray in the receiver side is shorter and thus the string to be deserialized is cut shorter.
solution:
use msg_control to contain the message size instead of fd. Then move fd to protobuf message.
alternative solution:
use first byte to carry the message size. but I don't see any reason why we use msg_control to transmit fd since it's essentially a message instead of transmission control message.
Comment 1 by bugdroid1@chromium.org
, Nov 18 2017