]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
crimson/net: fix dangling addrvec in SocketMessenger::bind().
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 16 Sep 2021 17:04:28 +0000 (17:04 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 16 Sep 2021 17:21:51 +0000 (17:21 +0000)
commit480273082718230d64d2c068db1b22f44997bdc8
tree5f48983d7afbd6d34e958a9cf4291ad3e1c9c99c
parentd4fc4ecf0aac78f1c767e7a77599364bdf29e062
crimson/net: fix dangling addrvec in SocketMessenger::bind().

`SocketMessenger::bind()` takes the address vector by `const&`.
while the callers in `OSD` are passing a temporary:

  ```cpp
  cluster_msgr->bind(pick_addresses(CEPH_PICK_ADDRESS_CLUSTER))
    // ...
  public_msgr->bind(pick_addresses(CEPH_PICK_ADDRESS_PUBLIC))
    // ...
  ```

  ```cpp
  entity_addrvec_t pick_addresses(int what) {
    // ...
    return addrs;
  }
  ```

The net result is a life-time mismatch and crashes like the following
one:

  ```
  WARN  2021-09-10 20:01:57,791 [shard 0] ms - [osd.0(client) v2:172.17.0.1:6800/3172806564@59988 >> mgr.? v2:172.17.0.7:6800/3846062660] waiting 3.2 seconds ...
  /opt/rh/gcc-toolset-9/root/usr/include/c++/9/bits/stl_iterator.h:820:17: runtime error: reference binding to misaligned address 0x000041b58ab3 for type 'const struct entity_addr_t', which requires 4 byte alignment
  0x000041b58ab3: note: pointer points here
  <memory cannot be printed>
  /opt/rh/gcc-toolset-9/root/usr/include/c++/9/bits/stl_vector.h:1132:16: runtime error: reference binding to misaligned address 0x000041b58ab3 for type 'const struct value_type', which requires 4 byte alignment
  0x000041b58ab3: note: pointer points here
  <memory cannot be printed>
  /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/17.0.0-7486-g27cb19ed/rpm/el8/BUILD/ceph-17.0.0-7486-g27cb19ed/src/msg/msg_types.h:561:22: runtime error: reference binding to misaligned address 0x000041b58ab3 for type 'const struct entity_addr_t', which requires 4 byte alignment
  0x000041b58ab3: note: pointer points here
  <memory cannot be printed>
  Segmentation fault on shard 0.
  ```

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/net/SocketMessenger.cc