eclipse-cyclonedds / cyclonedds-cxx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

datatopic.hpp: populate_hash() does not populate the hash

clunietp opened this issue · comments

CycloneDDS-CXX e41e5c8 06 Nov 23

The following logic results in a failure to generate an instance's hash value, leading to an OOM in the underlying hopscotch hash table due to hash table key collisions.

Related: eclipse-cyclonedds/cyclonedds#1932

populate_hash

template <typename T>
void ddscxx_serdata<T>::populate_hash()
{
  if (hash_populated)
    populate_hash(*getT());
}

Solution: if the hash is not populated, populate the hash.

I was looking at the following stack trace just yesterday which now appears to match this issue.

I pulled master and can confirm the OOM issue appears to be resolved. My application was also publishing multiple updates to the same sample. @clunietp thanks for reporting and @eboasson thanks for the fix.

Thread 6 "recv" received signal SIGABRT, Aborted. [Switching to Thread 0x7ffff3b6d700 (LWP 95049)] __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 50 return ret; (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007ffff694cea5 in __GI_abort () at abort.c:79 #2 0x00007ffff7752bd4 in ddsrt_malloc (size=17179869192) at /home/jpg/git/cyclonedds/src/ddsrt/src/heap/posix/heap.c:43 #3 0x00007ffff774b3b0 in ddsrt_chh_resize (rt=0xc337c0) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:475 #4 0x00007ffff774b7e9 in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:547 #5 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #6 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #7 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #8 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #9 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #10 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #11 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #12 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #13 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #14 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #15 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #16 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #17 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #18 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #19 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #20 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #21 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #22 0x00007ffff774b7fc in ddsrt_chh_add_locked (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:548 #23 0x00007ffff774b831 in ddsrt_chh_add (rt=0xc337c0, data=0xdfd370) at /home/jpg/git/cyclonedds/src/ddsrt/src/hopscotch.c:554 --Type <RET> for more, q to quit, c to continue without paging-- #24 0x00007ffff767f58d in ddsi_tkmap_find (map=0xc33750, sd=0x7fffdc005ea0, create=true) at /home/jpg/git/cyclonedds/src/core/ddsi/src/ddsi_tkmap.c:191 #25 0x00007ffff767f5e2 in ddsi_tkmap_lookup_instance_ref (map=0xc33750, sd=0x7fffdc005ea0) at /home/jpg/git/cyclonedds/src/core/ddsi/src/ddsi_tkmap.c:204 #26 0x00007ffff76dbd8d in remote_make_sample (tk=0x7ffff3b69320, gv=0xc30e18, type=0xd444d0, vsourceinfo=0x7ffff3b69410) at /home/jpg/git/cyclonedds/src/core/ddsi/src/ddsi_receive.c:2081 #27 0x00007ffff7683702 in deliver_locally_fastpath (gv=0xc30e18, source_entity=0x7fffe4016640, source_entity_locked=true, fastpath_rdary=0x7fffe4016798, wrinfo=0x7ffff3b69440, ops=0x7ffff79b8340 <deliver_locally_ops>, vsourceinfo=0x7ffff3b69410) at /home/jpg/git/cyclonedds/src/core/ddsi/src/ddsi_deliver_locally.c:221 #28 0x00007ffff7683918 in ddsi_deliver_locally_allinsync (gv=0xc30e18, source_entity=0x7fffe4016640, source_entity_locked=true, fastpath_rdary=0x7fffe4016798, wrinfo=0x7ffff3b69440, ops=0x7ffff79b8340 <deliver_locally_ops>, vsourceinfo=0x7ffff3b69410) at /home/jpg/git/cyclonedds/src/core/ddsi/src/ddsi_deliver_locally.c:257 #29 0x00007ffff76dc61a in deliver_user_data (sampleinfo=0x7ffff7eeb000, fragchain=0x7ffff7eeaf78, rdguid=0x0, pwr_locked=1) at /home/jpg/git/cyclonedds/src/core/ddsi/src/ddsi_receive.c:2249 #30 0x00007ffff76dc6e7 in deliver_user_data_synchronously (sc=0x7ffff3b69bc0, rdguid=0x0) at /home/jpg/git/cyclonedds/src/core/ddsi/src/ddsi_receive.c:2276