Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2328

"member access within misaligned address" in _mongoc_rpc_scatter for OP_MSG

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.9.0
    • Affects Version/s: 1.9.0
    • Component/s: None
    • Labels:
      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?

      https://evergreen.mongodb.com/task_log_raw/mongo_c_driver_clang38_debug_compile_sanitizer_undefined_506e36a96b713822214eda939ff31df90f1aa615_17_10_14_13_31_38/0?type=T

            Assignee:
            Unassigned Unassigned
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: