-
Notifications
You must be signed in to change notification settings - Fork 62
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
loan_sample() returns illegal oparation when using FastDDS-Gen 2.5.0 and fastrtps.so.2.3.4 and 2.10.0 #193
Comments
@amdsobhy Which IDL produces that behavior? |
@MiguelCompany here is the IDL:
|
@amdsobhy The in-memory representation of that structure will not match the CDR representation. This implies that This is due to the padding present between
|
Thank you for the reply and the explanation. I thought that the generated code would handle such situation. Why doesn't cdr handle this situation so that the user does not have to worry about it? How can one guarantee in future implementation that the in-memory representation matches CDR representation? What are the rules to garantee such matching? I read that according to the standard padding is inserted into the struct to make it's size in multiples of 8 bytes. In my situation the header is 20 bytes so by adding another 4 bytes padding it becomes 24 bytes and a multiple of 8 and thus it fixes the problem of misalignment between cdr representation and memory representation, but what about the situation in point #3 you mentioned above? why does moving the eightbytes0 variable to the bottom of the Header struct solve the problem when the size of the struct is still the same? |
I have prepared this example so you can see the differences in memory representation |
Thank you for the great example. I thought the padding was inserted using fastcdr during serialization and not the compiler. From your example I see that this is the default padding inserted by the complier. Would it be okay to modify the generated headers and include compiler directives to disable padding? Also why doesn't fastcdr handle the compiler padding during serialization and deserialization? As far as I know compiler padding is different accross architectures, compilers and compiler versions, so what happens when two different machines are communicating over dds and each one of them has a different point of view of what the padding in the message look like? Shouldn't padding be abstracted from the reader and writer of the message through the middleware? |
same problem, is this a bug in ddsgen v2.5.0? |
@amdsobhy Sorry for my late reply. Let me try to explain how Fast DDS works behind the scenes when When the DataWriter is created, the type support is invoked to query the maximum size of the serialized (i.e. CDR) payload. The purpose of So in order for that operation to be legal, the CDR representation should match the in-memory representation of the generated type. That implies that the CDR padding and the compiler padding should match. The type generated by the IDL here would most probably have a padding different from the one mandated by the CDR spec. On previous Fast DDS Gen versions, the On Fast DDS Gen 2.5.0, we included a mechanism to better implement So, answering @nyanpasua , this is not a bug in v2.5.0. It is a bug-fix. |
When not using loans, CDR serialization and deserialization will take place. In this case, and the writer and the reader are abstracted with regards to padding. |
I am going to proceed and close this issue as it has already been answered. |
Thanks for @MiguelCompany 's explanation, but I can't agree your opinion. I think this modification is a kind of regression. The original intention of idl definition is to facilitate users. The purpose of loan sample is to improve performance. But this ”is_ plain” implementation imposes so many limitations on users, and also decrease usage scenario. Don't stick to the CDR specification. After all, the zero copy implementation of fastdds is also not within the specifications of RTPS. In addition, the development trend of modern C++ is the convenience of developers, otherwise there wouldn't be so many syntax sugars. |
loan_sample() returns RETCODE_ILLEGAL_OPERATION when using FastDDS-Gen 2.5.0, tested with fastrtps.so.2.3.4 and 2.10
Issue does not happen when using FastDDS-Gen 2.1.0
The text was updated successfully, but these errors were encountered: