ADLINK-IST / opensplice

This is the Vortex OpenSplice Community Edition source repository. For our commercial offering see
https://www.adlinktech.com/en/vortex-opensplice-data-distribution-service
Apache License 2.0
259 stars 157 forks source link

V6.9 idlpp -l isoc++2 generated code for nested structs seg faults on DDS write #109

Closed richardbostock closed 3 years ago

richardbostock commented 4 years ago

I have run into a problem whereby idlpp -l isoc++2 generated code for nested structs seg faults on DDS write. This was working under 6.7.180404OSS, but isn't under VortexOpenSplice-6.9.190925OSS and 6.9.181127OSS

Example The easiest way to reproduce this is to modify the provided example: examples/dcps/Tutorial/isocpp2

If you change Chat.idl module as below, compile it using the Makefile, and then run ./Chatter:

module Chat {

const long MAX_NAME = 32;
typedef string<MAX_NAME> nameType;

struct details {
    string info1;
    string info2;
};

struct ChatMessage {
    long      userID;          // owner of message
    long      index;           // message number
    string    content;         // message body
    details   extra;           // test idlpp output
};

pragma keylist ChatMessage userID

struct NameService {
    long     userID;           // unique user identification
    nameType name;             // name of the user
};

pragma keylist NameService userID

struct NamedMessage {
    long     userID;           // unique user identification
    nameType userName;         // user name
    long     index;            // message number
    string   content;          // message body
};

pragma keylist NamedMessage userID

};

Output: Segmentation fault (core dumped)

GDB Output Thread 1 "Chatter" received signal SIGSEGV, Segmentation fault. 0x00007ffff75b5076 in __Chat_ChatMessage__copyIn(c_type_s, Chat::ChatMessage const, _Chat_ChatMessage*) () from /home/simon/projects/VortexOpenSplice-6.9.190925OSS/HDE/x86_64.linux/examples/dcps/Tutorial/isocpp2/libISO_Cxx_V2_Tutorial_Types.so

(gdb) bt

0 0x00007ffff75b5076 in __Chat_ChatMessage__copyIn(c_type_s, Chat::ChatMessage const, _Chat_ChatMessage*) () from /home/simon/projects/VortexOpenSplice-6.9.190925OSS/HDE/x86_64.linux/examples/dcps/Tutorial/isocpp2/libISO_Cxx_V2_Tutorial_Types.so

1 0x00007ffff6f9985c in u_writerRegisterInstance () from /home/simon/projects/VortexOpenSplice-6.9.190925OSS/HDE/x86_64.linux/examples/dcps/Tutorial/isocpp2/../../../../lib/libddskernel.so

2 0x00007ffff731855a in org::opensplice::pub::AnyDataWriterDelegate::register_instance(u_writer_s, void const, dds::core::Time const&) ()

from /home/simon/projects/VortexOpenSplice-6.9.190925OSS/HDE/x86_64.linux/examples/dcps/Tutorial/isocpp2/../../../../lib/libdcpsisocpp2.so

3 0x00007ffff7ba764d in dds::pub::DataWriter<Chat::ChatMessage, dds::pub::detail::DataWriter>::register_instance(Chat::ChatMessage const&) ()

from /home/simon/projects/VortexOpenSplice-6.9.190925OSS/HDE/x86_64.linux/examples/dcps/Tutorial/isocpp2/libISO_Cxx_V2_Tutorial_Impl.so

4 0x00007ffff7ba431e in examples::dcps::Tutorial::isocpp::Chatter(int, char**) () from /home/simon/projects/VortexOpenSplice-6.9.190925OSS/HDE/x86_64.linux/examples/dcps/Tutorial/isocpp2/libISO_Cxx_V2_Tutorial_Impl.so

5 0x00007ffff77d7830 in __libc_start_main (main=0x4005f0
, argc=1, argv=0x7fffffffdef8, init=, fini=, rtld_fini=, stack_end=0x7fffffffdee8) at ../csu/libc-start.c:291

6 0x0000000000400629 in _start ()

Analysis I've looked a bit in to this and in the ChatSplDcps.cpp the command c_memberType(c_structureMember(dbType, 3)) appears to be causing the issue. This is the primary change from 6.7.

if(V_COPYIN_RESULT_IS_OK(result)){ extern v_copyin_result Chat_details__copyIn(c_type, const Chat::details , _Chat_details ); result = Chat_details__copyIn(c_memberType(c_structureMember(dbType, 3)), &from->extra(), &to->extra); }

richardbostock commented 3 years ago

This is fixed in the latest version that was recently released.