-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 1.9.0
-
Component/s: None
-
None
After implementing OP_MSG in the mock server we now do _mongoc_rpc_scatter on OP_MSG. (That's for parsing OP_MSG; before, we had only generated OP_MSG.) This has triggered a warning when executing with clang's undefined behavior sanitizer:
[2017/10/14 12:07:53.085] Begin /Cluster/cluster_time/query/, seed 3682232949 [2017/10/14 12:07:53.085] src/mongoc/op-msg.def:1:1: runtime error: member access within misaligned address 0x7fd2b4000e94 for type 'mongoc_rpc_section_t' (aka 'struct _mongoc_rpc_section_t'), which requires 8 byte alignment [2017/10/14 12:07:53.085] 0x7fd2b4000e94: note: pointer points here [2017/10/14 12:07:53.086] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
The error occurs on the second of these two lines (part of the macro that defines _mongoc_rpc_scatter_msg):
mongoc_rpc_section_t *section = &rpc->_name[rpc->n_##_name]; \ section->payload_type = buf[0]; \
The mongoc_rpc_section_t struct is defined with pragma pack(1) which seems unnecessary, and the cause of this warning. Can we just not override the default packing when defining this struct and the other wire protocol structs?